Resampling of a DataFrame by 1 Hour in pandas gives unexpected NaN values
I have a dataframe having 3 columns. 1st Column contains date ( like 2020-07-01,2020-07-01...); 2nd column contains time ( like 00:00:00, 01:00:00...) for one month on hourly basis and 3rd column contains the corresponding values of a variable including some missing rows (i.e., missing data) in the dataframe. Also some values in the 2nd column (time) is like 15:06:55, 16:00:01 etc.
I want to resample the dataframe by 1 Hour and fill NaN values only in place of the missing data. In my case, Resampling gives NaN values to the missing data place as well as where the time is like 15:06:55, 16:00:01 etc. Please help me to solve the issue. Thanks in advance.
df['Date-Time'] = pd.to_datetime(df[0] + df[1],format='%Y-%m-%d%H:%M:%S')
df = df.set_index('Date-Time')
df = df.resample('1H').fillna(method=None)
This code gives NaN values in place of missing data as well as where the time is like 15:06:55, 16:00:01, 17:00:01 etc. I want to resample the dataframe by 1 Hour and fill NaN values only in place of the missing data. I have uploaded an image of the dataframe before resampling. Please help me to solve the issue. Thanks in advance.I have uploaded an image of the dataframe before resampling.