
上QQ阅读APP看书,第一时间看更新
086 根据指定的日期切片筛选数据
此案例主要演示了使用切片根据日期类型的行标签在DataFrame中筛选指定日期范围的数据。当在Jupyter Notebook中运行此案例代码之后,将在DataFrame中筛选2021-09-13到2021-09-15的数据,效果分别如图086-1和图086-2所示。

图086-1

图086-2
主要代码如下。

在上面这段代码中,df[datetime.datetime(2021,9,13):datetime.datetime(2021,9,15)]表示在df中筛选2021-09-13到2021-09-15期间的数据。
此案例的主要源文件是MyCode\H827\H827.ipynb。