I have a column of timestamps that need to be converted into period ('Month'). e.g.
1985-12-31 00:00:00 to 1985-12
Pandas have a .to_period function, but it only works for timestamps index, not column. So you can only have a period index, but not a period column?
And it only work if timestamps is the only index. That is, if timestamps are part of a multIndex, the .to_period() function doesn't work as well.
It seems that Pandas assume people will always use timestamps and periods as index, but not a single column, which is apparently not the case.
Anyway I can get around with this? Or if not in Pandas, can it be done in numpy?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…