I have two dataframes df1 and df2 df1 contains month and two date columns
df1
Month Month_Start Month_End Month1 2022-03-27 2022-04-30 Month2 2022-05-01 2022-05-28 Month3 2022-05-01 2022-06-25 another data frame df2
start_Month end_Month price 2022-03-27 2260-12-31 1 2022-03-27 2260-12-31 2 2022-03-27 2260-12-31 3 if Month_Start and Month_end of df1 is in between start_Month and end_Month of df2, assign price column value to Month column of df1
like following result
Month price Month1 1 Month2 1 Month3 1 I tried using for loops
for i in range(len(df2)): for j in range(len(df1)): if df2['start_Month'][i] <= df1['Month_Start'][j]<= df1['Month_End'][j] <= df2['end_Month'][i]: new.loc[len(new.index)] = [df1['month'][j], df2['price'][i]] but taking lot of time for execution for 1000+ rows.
ANY IDEAS?