Code Sample, a copy-pastable example if possible
import pandas as pd
df = pd.DataFrame({'Item Num': [456, 456, 340, 340, 500, 500, 520, 520, 645, 645],
'Price Type': [4,1,1,1,2,1,1,1,3,1],
'Sales Date': ['2017-12', '2018-01', '2017-12', '2018-01',
'2017-12', '2018-01', '2017-12', '2018-1',
'2017-12', '2018-01']})
df2 = pd.DataFrame({'Item Num': [456, 456, 340, 340, 500, 500, 520, 520, 645, 645],
'Price Type': [4,1,1,1,2,1,1,1,3,1],
'Sales Date': ['2016-12', '2016-01', '2016-12', '2016-01',
'2016-12', '2016-01', '2016-12', '2016-1',
'2016-12', '2016-01']})
df3 = pd.merge(df, df2, how = 'outer', left_on=['Item Num, Price Type'], right_on=['Item Num', 'Price Type'])
Traceback (most recent call last):
File "<ipython-input-1-12e820f348fe>", line 16, in <module>
df3 = pd.merge(df, df2, how = 'outer', left_on=['Item Num, Price Type'], right_on=['Item Num', 'Price Type'])
File "C:\Users\tkelly\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\reshape\merge.py", line 57, in merge
validate=validate)
File "C:\Users\tkelly\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\reshape\merge.py", line 560, in __init__
self._validate_specification()
File "C:\Users\tkelly\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\reshape\merge.py", line 978, in _validate_specification
raise ValueError("len(right_on) must equal len(left_on)")
ValueError: len(right_on) must equal len(left_on)
#### Problem description
Receiving ValueError: len(right_on) must equal len(left on).
This dataframes should merge fine instead of throwing error.
Expected Output
Merged dataframes.
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Windows
OS-release: 2012ServerR2
machine: AMD64
processor: Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None
pandas: 0.22.0
pytest: 3.0.7
pip: 9.0.1
setuptools: 38.4.0
Cython: 0.25.2
numpy: 1.13.3
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.2.2
numexpr: 2.6.2
feather: None
matplotlib: 2.1.0
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 1.0.2
lxml: 3.7.3
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.13
pymysql: 0.7.11.None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
Comment From: TomAugspurger
Your left_on
is messed up: left_on=['Item Num, Price Type']
You're missing quotes between the two items.