Python 熊猫:删除带有日期的字符串
我有:Python 熊猫:删除带有日期的字符串,python,datetime,pandas,indexing,dataframe,Python,Datetime,Pandas,Indexing,Dataframe,我有: ID,"address","used_at","active_seconds","pageviews" 71ecd2aa165114e5ee292131f1167d8c,"auto.drom.ru",2014-05-17 10:58:59,166,2 71ecd2aa165114e5ee292131f1167d8c,"auto.drom.ru",2016-07-17 17:34:07,92,4 70150aba267f671045f147767251d169,"avito.ru/*/av
ID,"address","used_at","active_seconds","pageviews"
71ecd2aa165114e5ee292131f1167d8c,"auto.drom.ru",2014-05-17 10:58:59,166,2
71ecd2aa165114e5ee292131f1167d8c,"auto.drom.ru",2016-07-17 17:34:07,92,4
70150aba267f671045f147767251d169,"avito.ru/*/avtomobili",2014-06-15 11:52:09,837,40
bc779f542049bcabb9e68518a215814e,"auto.yandex.ru",2014-01-16 22:23:56,8,1
bc779f542049bcabb9e68518a215814e,"avito.ru/*/avtomobili",2014-01-18 14:38:33,313,5
bc779f542049bcabb9e68518a215814e,"avito.ru/*/avtomobili",2016-07-18 18:12:07,20,1
我需要删除超过2016-06-30
时使用的所有字符串。我如何才能做到这一点?与以下一起使用:
或者您可以通过年
、月
和日
来定义日期时间:
print (df[df.used_at.dt.date > pd.datetime(2016, 6, 30).date()])
ID address \
1 71ecd2aa165114e5ee292131f1167d8c auto.drom.ru
5 bc779f542049bcabb9e68518a215814e avito.ru/*/avtomobili
used_at active_seconds pageviews
1 2016-07-17 17:34:07 92 4
5 2016-07-18 18:12:07 20 1
print (df[df.used_at.dt.date > pd.datetime(2016, 6, 30).date()])
ID address \
1 71ecd2aa165114e5ee292131f1167d8c auto.drom.ru
5 bc779f542049bcabb9e68518a215814e avito.ru/*/avtomobili
used_at active_seconds pageviews
1 2016-07-17 17:34:07 92 4
5 2016-07-18 18:12:07 20 1