I use Pandas to structure and process data.
I have a DataFrame with dates in the form of index, Id and bit rate. I want to group my data by identifier and repeat the selection, at the same time, according to the time that applies to each identifier, and finally, save the bitrate estimate.
For example, given:
df = pd.DataFrame(
{'Id' : ['CODI126640013.ts', 'CODI126622312.ts'],
'beginning_time':['2016-07-08 02:17:42', '2016-07-08 02:05:35'],
'end_time' :['2016-07-08 02:17:55', '2016-07-08 02:26:11'],
'bitrate': ['3750000', '3750000'],
'type' : ['vod', 'catchup'],
'unique_id' : ['f2514f6b-ce7e-4e1a-8f6a-3ac5d524be30', 'f2514f6b-ce7e-4e1a-8f6a-3ac5d524bb22']})
which gives:

This is my code to get a unique column for dates every time Id and bitrate:
df = df.drop(['type', 'unique_id'], axis=1)
df.beginning_time = pd.to_datetime(df.beginning_time)
df.end_time = pd.to_datetime(df.end_time)
df = pd.melt(df, id_vars=['Id','bitrate'], value_name='dates').drop('variable', axis=1)
df.set_index('dates', inplace=True)
which gives:

And now, time for a Resample! This is my code:
print (df.groupby('Id').resample('1S').ffill())
And this is the result:

This is exactly what I want to do! I have 38,279 logs with the same columns, and I have an error message when I do the same. The first part works fine and gives the following:

(df.groupby('Id'). resample ('1S'). ffill()) :
ValueError: cannot reindex a non-unique index with a method or limit
? Thnx!