'How do I select multiple time ranges in the same dataset to form a new sub-dataset?

Example of sub-dataset1 (desired output) First 20 rows of dataframe

Hello everyone, I have a rather convoluted dataset which i need to get some help with. I am trying to figure out how i can select multiple time ranges and dates in my dataset and bundle them together into sub-datasets which represent different activities, for comparison. For example: All data between these time ranges:

(08:42:11 & 08:42:38; 08:42:42 & 08:42:44; and 08:43:18 & 08:44:02) sub dataset 1 (3 peoples results from walking)

(08:44:53 & 08:45:03; 08:45:22 & 08:47:07; and 08:47:08 & 08:47:10) sub dataset 2 (3 peoples results from running)

The different time ranges here (just used as examples) represent different people participating in an activity. Each sub-dataset represents a different activity(walking and running). So, basically what i am trying to do it collate the data from each participant for each activity to then compare against each other. I would also need to specify the date (23rd in this example) as my actual dataset runs over multiple days.

There are articles on multiple dates and looking between 1 time range but i havent been able to find any literature on creating a dataframe with multiple time-slices so to speak.

So to summarise: The instrument ran continuously over the few days providing one big dataset which now needs splitting up by time/date, picking out each participants results for an activity and placing the combined data into a new subdataset which now represents all the results for that activity. And so on for each activity. I can then compare these against one another in boxplots or other analyses (i.e. walking vs running).

Any guidance here would be greatly appreciated!

f = h5py.File('data.h5', 'r')
df = pd.DataFrame(columns=['AF','Fl1','Fl2'])
df['AF']=f['data']['AF'][()]
df['Fl1']=f['data']['Fl1'][()]
df['Fl2']=f['data']['Fl2'][()]
df=df.set_index('Time')
df.index = pd.to_datetime(df.index, unit='s')
df.replace([np.inf, -np.inf], np.nan, inplace=True)
df=df.dropna()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source