Description
import pandas as pd
import numpy as np
from pandas.util.testing import assert_frame_equal
df = pd.DataFrame(np.arange(12).reshape(-1, 3),
columns=['a', 'b', 'c'])
df.index = pd.MultiIndex.from_tuples(
[(1, 2000), (1, 2001), (2, 2000), (2, 2001)],
names=['id', 'year'])
s = pd.Series([True, True], index=[1, 3], name='flag')
s.index.name = 'id'
# These two should *NOT* be the same, but they are both like a standard 'inner'
left = df.join(s, how='left')
inner = df.join(s, how='inner')
assert_frame_equal(left, inner)
# These two should *NOT* be the same, but they are both like a standard 'outer'
right = df.join(s, how='right')
outer = df.join(s, how='outer')
assert_frame_equal(right, outer)
# A standard 'left' merge is actually achieved with a MultiIndex by invoking `how='right'`
std_left = df.reset_index('year').join(s, how='left').set_index('year', append=True)
assert_frame_equal(right, std_left)
My impression from the example in #6356 is that the effect of how
should not change with a MultiIndex. I know that #6363 is what was actually merged, so please correct me if my understanding is wrong.
INSTALLED VERSIONS
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.16.1
nose: 1.3.6
Cython: 0.22
numpy: 1.9.2
scipy: 0.15.1
statsmodels: 0.6.1
IPython: 3.1.0
sphinx: None
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.4
bottleneck: 1.1.0dev
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.4.3
openpyxl: None
xlrd: 0.9.3
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.4
pymysql: None
psycopg2: None