Commit 60bb07ae authored by 张彦钊's avatar 张彦钊

change

parent 67921e0f
......@@ -55,7 +55,7 @@ def all_click(x):
sum = sum + tmp
total.append(sum)
return tuple(total)
return sum
def cpc_click(x):
......@@ -111,7 +111,7 @@ def cpc_click(x):
cpc.append(sum)
return tuple(cpc)
return sum
......@@ -127,14 +127,20 @@ if __name__ == '__main__':
spark = SparkSession.builder.config(conf=sparkConf).enableHiveSupport().getOrCreate()
clicks = []
cpcs = []
for i in range(1,26):
dates = []
for i in range(1,3):
clicks.append(all_click(i))
cpcs.append(cpc_click(i))
date_str = (datetime.date.today() - datetime.timedelta(days=i)).strftime("%Y%m%d")
dates.append(date_str)
print("clicks")
print(clicks)
print("cpcs")
print(cpcs)
df = pd.DataFrame({'date': dates,
'clicks': clicks,"cpc":cpcs})
df.to_csv('/home/gmuser/cpc.csv', index=False)
# rdd = spark.sparkContext.parallelize(cpcs)
# df = spark.createDataFrame(rdd).toDF.toPandas()
# df.to_csv('/home/gmuser/cpc.csv',index=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment