I have a dataframe with the following structure.
I would like to select the data in the text column in chunks of two weeks, based upon the datetime column.
What would be the most efficient way to do this?
text_column datetime_column
0 jfklsjf 2014-05-10 22:42:35
1 ldjskfj 2014-05-14 03:04:24
2 dslffkf 2014-07-03 23:05:17
. . .
. . .
If you are looking for specific chunks, you can do just a normal filter using pandas
df[(df['datetime_colum']>='2014-04-10') & (df['datetime_column']<'2014-05-10')]
My example there will get you just the days that are for october 4th 2014. You can change the dates to get more days, if you don't already before doing this make sure the datetime column is an pandas datetime column. You can do this by
df['datetime_column']= pd.to_datetime(df['datetime_column'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.