'Hourly observation based on timedate data
I have a long data set (>100000 values) of data time values (six columns: year, month, day, hour, min, second). Each datatime entry represnet one observation. Using pd.to_datetime, I convert the dataset to DateTime format.
t=df[['year', 'month', 'day', 'hour', 'minute', 'second']]
t = pd.to_datetime(t)
t.name = 'time'
ev_t=pd.DataFrame(t)
df1 = ev_t.set_index('time')
# data is as below
0 2015-01-22 00:00:27.540
1 2015-01-22 00:08:58.890
2 2015-01-22 02:02:41.040
3 2015-01-22 02:19:56.900
4 2015-01-22 02:36:07.080
...
152916 2022-02-05 13:29:24.210
152917 2022-02-05 15:06:58.710
152918 2022-02-05 16:30:13.370
152919 2022-02-05 17:48:06.460
152920 2022-02-05 23:45:41.480
I need to calculate hourly observations (2015:01:01 00:01:01 to 2019:12:31 23:59:59). The key point is some time, we have an issue of missing data so maybe no data for a few days or weeks. I want to get hourly. Here is my attempt:
ev_t = df1.groupby('time', as_index=False).resample('6H').ffill()
But this did not work. May someone help me here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
