Commit 63ef9d59 authored by 张彦钊's avatar 张彦钊

跑最近3天的cpc数据

parent e81a83ab
...@@ -280,26 +280,36 @@ if __name__ == '__main__': ...@@ -280,26 +280,36 @@ if __name__ == '__main__':
.set("spark.driver.maxResultSize", "8g").set("spark.sql.avro.compression.codec", "snappy") .set("spark.driver.maxResultSize", "8g").set("spark.sql.avro.compression.codec", "snappy")
spark = SparkSession.builder.config(conf=sparkConf).enableHiveSupport().getOrCreate() spark = SparkSession.builder.config(conf=sparkConf).enableHiveSupport().getOrCreate()
for os in ["ios","android"]: # for os in ["ios","android"]:
all_list = [] # all_list = []
for i in range(1,3): # for i in range(1,3):
date_str = (datetime.date.today() - datetime.timedelta(days=i)).strftime("%Y%m%d") # date_str = (datetime.date.today() - datetime.timedelta(days=i)).strftime("%Y%m%d")
tmp_list = [date_str] # tmp_list = [date_str]
tmp_list.extend(os_all_click(i,os)) # tmp_list.extend(os_all_click(i,os))
tmp_list.extend(os_cpc_click(i,os)) # tmp_list.extend(os_cpc_click(i,os))
all_list.append(tmp_list) # all_list.append(tmp_list)
df = pd.DataFrame(all_list) # df = pd.DataFrame(all_list)
df = df.rename(columns={0: "date",1: "search", 2: "xiangguan",3:"home",4:"service_home", # df = df.rename(columns={0: "date",1: "search", 2: "xiangguan",3:"home",4:"service_home",
5: "all_clcik", # 5: "all_clcik",
6: "cpc_search", 7: "cpc_xiangguan",8:"cpc_home",9:"cpc_service_home", # 6: "cpc_search", 7: "cpc_xiangguan",8:"cpc_home",9:"cpc_service_home",
10:"cpc_all"}) # 10:"cpc_all"})
df.to_csv('/home/gmuser/cpc_{}.csv'.format(os), index=False) # df.to_csv('/home/gmuser/cpc_{}.csv'.format(os), index=False)
# df = df.rename(columns={0: "date",1: "search", 2: "xiangguan",3:"home",4:"service_home", all_list = []
# 5: "all_clcik", for i in range(1, 4):
# 6: "cpc_search", 7: "cpc_xiangguan",8:"cpc_home",9:"cpc_service_home", date_str = (datetime.date.today() - datetime.timedelta(days=i)).strftime("%Y%m%d")
# 10:"cpc_all"}) tmp_list = [date_str]
# df.to_csv('/home/gmuser/cpc.csv', index=False) tmp_list.extend(all_click(i))
tmp_list.extend(cpc_click(i))
all_list.append(tmp_list)
df = pd.DataFrame(all_list)
df = df.rename(columns={0: "date",1: "search", 2: "xiangguan",3:"home",4:"service_home",
5: "all_clcik",
6: "cpc_search", 7: "cpc_xiangguan",8:"cpc_home",9:"cpc_service_home",
10:"cpc_all"})
df.to_csv('/home/gmuser/cpc_1011.csv', index=False)
spark.stop() spark.stop()
......
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