python - pandas - check if date exists in dataframe
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a dataframe like this: category date number 0 Cat1 2010-03-01 1 1 Cat2 2010-09-01 1 2 Cat3 2010-10-01 1 3 Cat4 2010-12-01 1 4 Cat5 2012-04-01 1 5 Cat2 2013-02-01 1 6 Cat3 2013-07-01 1 7 Cat4 2013-11-01 2 8 Cat5 2014-11-01 5 9 Cat2 2015-01-01 1 10 Cat3 2015-03-01 1 I would like to check if a date is exist in this dataframe but I am unable to. I tried various ways as below but still no use: if pandas.Timestamp("2010-03-01 00:00:00", tz=None) in df['date'].values: print 'date exist' if datetime.strptime('2010-03-01', '%Y-%m-%d') in df[