我很难理解PeriodIndex和DateTimeIndex之间的区别,以及何时使用它.特别是,使用Periods而不是Timestamps似乎更自然,但最近我发现Timestamps似乎提供了相同的索引功能,可以与timegrouper一起使用,并且还可以更好地使用Matplotlib的日期功能.所以我想知道是否有任何理由使用Periods(PeriodIndex)?
ctl*_*ctl 14
期间可用于检查特定事件是否在特定时期内发生.基本上,Period表示时间间隔,而Timestamp表示时间点.
# For example, this will return True since the period is 1Day. This test cannot be done with a Timestamp.
p = pd.Period('2017-06-13')
test = pd.Timestamp('2017-06-13 22:11')
p.start_time < test < p.end_time
Run Code Online (Sandbox Code Playgroud)
我认为使用Periods/Timestamps的最简单的原因是他/她的代码是否需要来自Period和Timestamp的属性.
| 归档时间: |
|
| 查看次数: |
2445 次 |
| 最近记录: |