其他分享
首页 > 其他分享> > 【449】backup get weekly tweets

【449】backup get weekly tweets

作者:互联网

import pandas as pd
from datetime import datetime

fn = r"D:\OneDrive - UNSW\tweets_flu.csv"
df = pd.read_csv(fn)
for i in range(len(df)):
	t = df.iloc[i]['created_at']
	w = datetime.strptime(t, "%Y-%m-%d %H:%M:%S").strftime("%W")
	ws.append(w)

ws = []
df['ws'] = ws
df['ws'].value_counts()

 

import pandas as pd
from datetime import datetime

fn = r"D:\OneDrive - UNSW\tweets_flu.csv"
df = pd.read_csv(fn)
for i in range(len(df)):
	t = df.iloc[i]['created_at']
	w = datetime.strptime(t, "%Y-%m-%d %H:%M:%S").strftime("%W")
	ws.append(w)

ws = []
df['ws'] = ws
df['ws'].value_counts()

wss = []

for i in a.index:
	wss.append((i, a[i]))

sorted(wss, key=lambda x:x[0])
[('12', 56), ('13', 22), ('14', 41), ('15', 52), ('16', 25), ('17', 45), ('18', 63), ('19', 54), ('20', 51), ('21', 143), ('22', 77), ('23', 53), ('24', 133), ('25', 93), ('26', 77), ('27', 125), ('28', 63), ('29', 67), ('30', 56), ('31', 67), ('32', 62), ('33', 67), ('34', 54), ('35', 41), ('36', 43), ('37', 24), ('38', 29), ('39', 33), ('40', 14)]

  

 

标签:449,df,datetime,ws,pd,tweets,import,csv,weekly
来源: https://www.cnblogs.com/alex-bn-lee/p/11829709.html