这是问题:Find out how much time and over how many separate days did R.Lennon work on administering the Jira Server between August and September.
csv里是这样的
我才开始学习timeseries部分,大概逻辑有了,但是不知道怎么用代码表达。请大神帮忙提一点建议,谢谢!
怪我咯2017-04-18 10:18:45
Split Date field using re.split
import csv,re
with open('xxx.csv','rb') as rf:
reader = csv.reader(rf)
with open('xxx_new.csv','wb') as wf:
writer = csv.writer(wf)
headers = reader.next()
writer.writerow(headers)
for row in reader:
t = re.split('\W+',row[1])
# row[1]为Date字段,被拆为['1', '11', '2016', '14', '17']
if int(t[1]) == 11: # 假设你想要11月数据
writer.writerow(row)
阿神2017-04-18 10:18:45
You said timeseries, did you use pandas?
If it’s pandas, it’s actually quite simple. Assume that the name of datefrmae is df
First make sure that the Date column is converted to DatetimeIndex. This can be done with df['newdate']=pd.DatetimeIndex(df['date'])
Then filter df[df['newdate' ].dt.month==9] can filter out all September data,