how to fill missing date with certain time frequency?

I have a dataframe with columns being date time every 30min or sometime every 10 min. There are missing data and dates for few days. I'd like to fill missing data with zero or NaN with same time frequency. How to do it?

I found below similar question. But difference of my question is time frequency. I'd like to keep using same 30 minutes rather than using period_range for daily data filling.

sometimes, my data has 10 min time frequency. Basically I'd like to fill missing dates with same existing time frequency.

pandas fill missing dates in time series

I am pasting some data here for your reference.

Depth   5/19/2022 18:51 5/19/2022 19:21 5/19/2022 19:51 5/19/2022 20:21 5/19/2022 20:51 5/19/2022 21:21 5/19/2022 21:51 5/25/2022 0:22  5/25/2022 0:52  5/25/2022 1:22  5/25/2022 1:52  5/25/2022 2:22  5/25/2022 2:52
600 200.6   200.6   200.5   200.7   201.2   201 200.7   171.7   171.7   171.4   171 170.7   170.7
601 200.6   200.7   200.6   200.8   201.3   201.1   200.8   171.7   171.9   171.5   171.2   170.7   170.9
602 200.6   200.6   200.6   200.9   201.3   201 200.8   171.6   172.1   171.5   171.3   170.7   171
603 200.7   200.5   200.7   200.9   201.2   200.9   200.8   171.7   172.2   171.6   171.3   170.9   171.1
604 200.7   200.6   200.8   200.9   201.2   200.9   200.8   172 172.3   171.8   171.5   171.1   171.2
605 200.8   200.7   200.8   201 201.1   200.9   200.7   172.3   172.4   172 171.6   171.3   171.4
606 200.9   200.9   201 201.1   201 201 200.8   172.5   172.6   172.2   171.8   171.6   171.6
607 200.9   201 201.1   201.1   201 201.1   200.9   172.7   172.7   172.3   172.1   171.8   171.7
608 200.8   200.9   201.1   201 200.9   200.9   200.9   172.8   172.8   172.3   172.2   171.9   171.8
609 200.8   200.8   201.1   201 200.9   200.8   201 173 172.9   172.4   172.2   172.1   171.8
610 200.7   200.7   201.1   200.9   201 200.8   200.9   173.1   173 172.6   172.2   172.2   172
611 200.6   200.7   200.9   200.9   201.1   201 200.9   173.2   173.1   172.8   172.3   172.3   172.1
612 200.7   200.8   200.9   200.9   201.3   201.2   201 173.3   173.3   173.1   172.5   172.4   172.3
613 200.8   200.9   201 201.1   201.5   201.3   201 173.5   173.3   173.2   172.8   172.6   172.5
614 201.1   201 201.2   201.3   201.7   201.4   201.1   173.7   173.4   173.3   172.9   172.8   172.7

Thanks

enter image description here



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation