【发布时间】:2021-08-14 10:17:14
【问题描述】:
for row in data['column_name']: if row.date() < datetime.today().date(): print(row,????)
我无法获取数据框中特定列的数据时间索引。我使用了这段代码,我想用该行返回该行的索引。谁能帮帮我?
【问题讨论】:
-
使用
loc,不要重复——例如df.loc[df['datetime'].dt.date < pd.Timestamp('now').date()]。如需详细解答,请提供minimal reproducible example。
标签: python pandas dataframe datetime indexing