2021年4月25日星期日

Adding missing windows of time to pandas dataframe

I have this following dataframe

                      doctets  Duration  Real First Packet                        2013-02-04 15:45:00       456        64  2013-02-04 15:50:00    282111     56576  2013-02-04 16:00:00    271426    173632  2013-02-04 16:05:00         0         0  ...                       ...       ...  2013-02-15 16:20:00         0         0  2013-02-15 16:25:00         0         0  2013-02-15 16:30:00     47255      6656  

However, I want the dates of my dataframe to always range from 2013-02-04 8:00:00 to 2013-02-15 17:00:00 in windows of 5 minutes. The missing windows will always have 'doctets' 0 and 'Duration' 0.

My desired output would look something like this:

                      doctets  Duration  Real First Packet  2013-02-04 8:00:00          0         0  2013-02-04 8:05:00          0         0  ...                       ...       ...                        2013-02-04 15:45:00       456        64  2013-02-04 15:50:00    282111     56576  2013-02-04 15:55:00    271426    173632  2013-02-04 16:00:00         0         0  ...                       ...       ...  2013-02-15 16:20:00         0         0  2013-02-15 16:25:00         0         0  2013-02-15 16:30:00     47255      6656  ...                       ...       ...  2013-02-15 16:55:00         0         0  2013-02-15 17:00:00         0         0    

In other words, I want to fill the dataframe with the missing dates from my desired date range

https://stackoverflow.com/questions/67258867/adding-missing-windows-of-time-to-pandas-dataframe April 26, 2021 at 06:35AM

没有评论:

发表评论