使用 to_datetime 函数,我得到日期以及打印出来的时间。我只需要日期。转换时有什么方法可以将其删除吗?
pd.to_datetime(pd.Series(日期))
- 0 2013-12-20 00:00:00
- 1 2013-12-21 00:00:00
- 2 2013-12-22 00:00:00
- 3 2013-12-23 00:00:00
代码:(我的数据没有时间,但它的打印时间。另外我想在对它进行分组后打印它时添加它的打印时间)
data = pd.read_csv('workingfile.csv')
data['WEEK'] = pd.to_datetime(data['WEEK'],dayfirst = True)
grouped = data.groupby(['UPC','WEEK'])
for (upc,week), group in grouped:
print week
WEEK
02/06/2013 00:00
09/06/2013 00:00
16/06/2013 00:00
23/06/2013 00:00
30/06/2013 00:00
07/07/2013 00:00
14/07/2013 00:00