你刚刚注意到""的一些奇怪的行为。 pandas数据框的功能。
我在feedTable pandas数据表中有两列日期,索引和名为' date_forecast_adjusted'的列。我需要改变一些日期,具体取决于日期是否已经在两列中。似乎我可以很容易地检查转移的日期是否在索引中,但是对于列," in"命令似乎不起作用。
我尝试了以下命令:
(datePD + i*timedelta(hours=24))
Timestamp('2015-12-28 00:00:00')
pd.to_datetime("28/12/2015",dayfirst=True)
Timestamp('2015-12-28 00:00:00')
feedTable[feedTable['date_forecast_adjusted']==
pd.to_datetime("28/12/2015",dayfirst=True)]['date_forecast_adjusted'][0]
Timestamp('2015-12-28 00:00:00')
feedTable[feedTable['date_forecast_adjusted']==(datePD +
i*timedelta(hours=24))]['date_forecast_adjusted'][0]
Timestamp('2015-12-28 00:00:00')
feedTable[feedTable['date_forecast_adjusted']==
pd.to_datetime("28/12/2015",dayfirst=True)]['date_forecast_adjusted'][0]==
(datePD + i*timedelta(hours=24))
True
(datePD + i*timedelta(hours=24)) in feedTable['date_forecast_adjusted']
False
pd.to_datetime("28/12/2015",dayfirst=True) in
feedTable['date_forecast_adjusted']
False
pd.to_datetime("28/12/2015",dayfirst=True) in
feedTable[feedTable['date_forecast_adjusted']==
pd.to_datetime("28/12/2015",dayfirst=True)]['date_forecast_adjusted']
False
pd.Series((datePD +
i*timedelta(hours=24))).isin(feedTable['date_forecast_adjusted'])
0 True
any(feedTable['date_forecast_adjusted'] ==
(datePD + i*timedelta(hours=24)) )
True
我会说in in function ...