0

I have two Pandas DataFrames with one column in common, namely "Dates". I need to merge these two where "Dates" correspond. with pd.merge() it does the expected but removes the uncorresponding values. I want to keep other values too.

Ex: I have historical data for a stock for 1 min. and a calculated indicator for 5min. data ie. for each 5 rows I have a new value calculated in 1 min Data Frame.

I know that Series.dt.floor method may reveal useful here but I couldn't figure out.

I concatenated respective "Dates" to calculated indicator Series so that I can merge them where column matches. I obtained a right result but missing values. I need a continuity of 1 min values, i.e. same indicator must be valid for the next 5 entries then the second indicator value's turn to be merged.

STerliakov
  • 4,983
  • 3
  • 15
  • 37
  • Duplicate found: https://stackoverflow.com/questions/68531077/python-pandas-how-to-combine-or-merge-two-difrent-size-dataframes-based-on-date?rq=1 – bugrahaskan Dec 21 '22 at 13:51

1 Answers1

0
df1.merge(df2, left_on='Dates', right_on='Dates')
phœnix
  • 367
  • 1
  • 9