码迷,mamicode.com
首页 > 其他好文 > 详细

【449】backup get weekly tweets

时间:2019-11-10 15:58:16      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:lambda   pen   das   str   val   time   lam   import   created   

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】backup get weekly tweets

标签:lambda   pen   das   str   val   time   lam   import   created   

原文地址:https://www.cnblogs.com/alex-bn-lee/p/11829709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!