I am trying to collect temperature for each hour of the year. After some scrapping, I have almost all temp value by hours but unfortunately, some data was missing and a total number of temp is only 8600 rather than 8783 that year 2016 have as hours. And unfortunately, I don't know from which specific hours the temp data is missing. So I have to fulfill temp data till I have all corresponding values to hours in the year 2016. Is there a way to fulfill temp series on random basis inserting values that are near to original ones that I have.
When I am using pd.concat(), all rows till 8783 indexes (in temp column), are filled with NaN due to fewer rows in temp(8600).
df = pd.concat([date_df, temp_df], axis =1)
Output:
datetime | temp
0 2016-01-01 01:00:00 -6°C
1 2016-01-01 02:00:00 -6°C
2 2016-01-01 03:00:00 -6°C
3 2016-01-01 04:00:00 -7°C
.....
8780 2016-12-31 22:00:00 NaN
8781 2016-12-31 23:00:00 NaN
8782 2017-01-01 00:00:00 NaN
So can I add missing temp values on random indexes and their values to be as nearest one's from the existing ones. Thanks in advance and may the force be with you!