【发布时间】:2017-05-01 06:22:34
【问题描述】:
我有这种日期格式的数据框
Date Week Number Influenza[it] Febbre[it] Rinorrea[it]
0 2008-01-01 1 220 585 103
1 2008-01-08 2 403 915 147
2 2008-01-15 3 366 895 136
3 2008-01-22 4 305 825 136
4 2008-01-29 5 311 837 121
... ...
我想像这个数据框一样将日期格式转换为 ISO 周日期格式(因为我需要根据年份和周将两个具有相同日期的数据框相交)。格式类似于“year-weeknumberoftheyear”。
0 2007-42
1 2007-43
2 2007-44
3 2007-45
4 2007-46
... ...
所以我能够以这种方式找到第一个数据帧的 ISO 周数:
wiki = pd.read_csv('file.csv', parse_dates=['Date'])
for i,d in wiki.iterrows():
print d.Date.isocalendar()[1]
输出:
1
2
3
4
...
但我不知道如何制作像第二个数据框那样的日期格式(以“year-weeknumberoftheyear”的方式)
【问题讨论】:
标签: python date pandas dataframe iso