如何改变pandas DataFrame索引的精度?

时间:2013-10-31 16:47:34

标签: pandas

我有一个带有DateTimeIndex索引的Pandas DataFrame。 DateTimeIndex有一个分钟精度,我想把它变成几天精度。 我能做的是:

df.index = df.index.values.astype('datetime64[D]')

有更好的方法吗?

1 个答案:

答案 0 :(得分:0)

答案很简单:

df.resample('D', how='first')