How Do I Extract Subsets From A Dataframe Based On A Datetime Column?
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
Solution 1:
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'])
Post a Comment for "How Do I Extract Subsets From A Dataframe Based On A Datetime Column?"