-1

I am trying to currently add a specific row to a DataFrame when the dates match up, here are examples of both df:

image

I am attempting to add the "SHILLER" value to the bottom DataFrame when the dates from the DataFrames match up, I have been trying this for awhile, and sadly I have no useful solutions to show. For example, each Date in the bottom DataFrame has a 'Open, High, Low, and Close,' I'd like to add a "SHILLER" value for each date that a shiller value is present, as in the first DataFrame, about once a month. in pseudocode something like: if current date of df == date of SHILLER value: then add SHILLER to new column in bottom df

Thanks in advance, and let me know if I need to be more clear.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • Welcome to Stack Overflow! Please include any relevant information [as text directly into your question](https://stackoverflow.com/editing-help), do not link or embed external images of source code or data. Images make it difficult to efficiently assist you as they cannot be copied and offer poor usability as they cannot be searched. See: [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/q/285551/15497888) – Henry Ecker May 25 '21 at 03:00
  • Please include a _small_ subset of your data as a __copyable__ piece of code that can be used for testing as well as your expected output for the __provided__ data. See [MRE - Minimal, Reproducible, Example](https://stackoverflow.com/help/minimal-reproducible-example), and [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/15497888). – Henry Ecker May 25 '21 at 03:01

1 Answers1

0

You can use pandas.merge()

pd.merge(left=df_OHLC, right=df_SHILLER, left_on='Date', right_on='Date', how='left')
Gusti Adli
  • 1,225
  • 4
  • 13