joining two pandas dataframes on date and
<p>I am trying to join two dataframes however after merging the two dataframes i get NaN for all the columns from one of the DataFrames (Master) but the column heading are there. </p>

<p>Below is the structure of each dataframe</p>

<pre><code>b.columns
Index(['Date', 'Ticker', 'Price'], dtype='object')

Master.columns
Index(['Ticker', 'Date', 'Previous Quarter', 'No. Of Shares', 'Action'], dtype='object')

b.dtypes
Date      datetime64[ns]
Ticker            object
Price            float64
dtype: object

Master.dtypes
Ticker                      object
Date                datetime64[ns]
Previous Quarter             int64
No. Of Shares                int64
Action                      object
dtype: object
</code></pre>

<p>i have tried:</p>

<pre><code>M1 = pd.merge(left=b,right=Master, how ='left', left_on=['Date', 'Ticker'], right_on=['Date', 'Ticker'])
</code></pre>

<p>this might be expected behavior.
you have specified <code>how = 'left'</code> which means you are looking for key combinations from your left dataframe only. If there aren't exact(!) key matches in the right dataframe, you are going to get NaN's in the joined table. You can find more info on this argument <a href="http://pandas.pydata.org/pandas-docs/stable/merging.html" rel="nofollow">here</a>.</p>

<p>I suspect you have no exact matches in your key columns?</p>

<p>Also, if you specify <code>left_on</code> and <code>right_on</code> to be the same, you might as well only specify <code>on</code>.</p>

python pandas