#StackBounty: #python-3.x #pandas #datetime #filter #time-series How to filter time series if data exists at least data every 6 hours?

Bounty: 50

I’d like to verify if there is data at least once every 6 hours per ID, and filter out the IDs that do not meet this criteria.

I try to use the same method for filtering one per day, but having trouble adapting the code.

# add day column from datetime index
df['1D'] = df.index.day
# reset index
daily = df.reset_index()
# count per ID per day. Result is per ID data of non-zero 
a = daily.groupby(['1D', 'id']).size()
# filter by right join 
filtered = a.merge(df, on = id", how = 'right')

I cannot figure out how to adapt this for the following 6hr periods each day: 00:01-06:00, 06:01-12:00, 12:01-18:00, 18:01-24:00.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.