Consider I have dataframe which the first column is the datetime, and the other columns are data in the specified datetime (Data is collected hourly, so first column of every row is one hour after the previous row). In this dateframe data for some datetimes are missed. I want to make a new dataframe in which missing rows are replaced with the related datetime and NaNs for other columns.
I tried to read the dataframe from a csv as first DF, and created an empty DF in a loop to create datetime for every hour chronologically, then I take the data from first DF and put it in the second DF and if there is no data from first DF for the specified datetime I put NaN in the row.
This works for me, but it's very slow and takes 3 days to run for 70000 rows and I guess there is an efficient and pythonic way to do this.
I guess there is a better way like this one but I need it for datetime.
I'm looking for an answer like Replacing one data frame value from another based on timestamp Criterion but just with datetime.