我有一個Twitter的數據幀像這樣,如何計算twitter的日常詞頻?
>>>twitdata=pd.read_csv('D:\\twit-data.csv')
>>>twitdata
tweet_id user_id user_name t_date t_time tweets
4.05323E+17 82142636 1nvestor 11/26/2013 8:12:00 Fidelity reports that $TSN stock gets called away. Position now closed.
2.53585E+17 22042454 Kiplinger 10/3/2012 15:57:00 Did you know that every $100 bump in avg. home prices lifts consumer spending by $5? http://t.co/zXRbWJzR
...
我想算一個特定字的每日頻率,說iphone
,並獲得其日常的頻率一樣的結果,
date frequency
2011-01-01 530
2011-01-02 550
...
我如何設計一個程序來實現這個?
看看這個:http://stackoverflow.com/questions/6017948/word-counts-in-python-using-regular-expression。你需要也許一行一行地工作。使用'df [column] .apply()',並將計數存儲在DataFrame的另一列中。 – Kartik