1

I have two dataframes. One is minutely spaced values for the whole year and another hourly spaced values of the whole year. Both the dataframes look like this Dataframe_1 Dataframe_2. What I want to do is take the hourly values of the temperature from Dataframe_2 (df_temp) and insert them in Dataframe_1 (df_main). So all the minutes of each hour (in DataFrame_1) will have the same hourly temperature values as in DataFrame_2. The In output it should look like thisOutput Dataframe

I currently us the following code. It takes 8s to execute. #

df_main = df_main.set_index('Timestamp')
df_temp = df_temp.set_index('Timestamp')

for index in df_temp.index:
 for j  in range (60):
    a = df_temp._get_value(index, "Temperature")
    df_main._set_value(index + timedelta(minutes=j),"Temp",a )

I know there is a better and faster way. Please guide me. Thanks in advance.

  • Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – noah Nov 11 '20 at 23:27

0 Answers0