I have a pandas DataFrame with the following values:
df =
1970-01-01 00:00:18 1 1 0 1 0
1970-01-01 00:00:19 0 0 0 1 0
1970-01-01 00:00:20 0 0 0 1 0
1970-01-01 00:00:25 0 1 0 0 1
1970-01-01 00:00:26 0 0 0 0 1
Now, I want to add rows for every missing second, and fill the values of the new row with zeros.
df =
1970-01-01 00:00:18 1 1 0 1 0
1970-01-01 00:00:19 0 0 0 1 0
1970-01-01 00:00:20 0 0 0 1 0
1970-01-01 00:00:21 0 0 0 0 0
1970-01-01 00:00:22 0 0 0 0 0
1970-01-01 00:00:23 0 0 0 0 0
1970-01-01 00:00:24 0 0 0 0 0
1970-01-01 00:00:25 0 1 0 0 1
1970-01-01 00:00:26 0 0 0 0 1
I looked into reindex and resample but it didn't see a way to make it work.
Ideally, I would also like to delete the '1970-01-01' part from the timestamp. But this doesn't have priority.