Closed
Description
Expected
Regardless of the arguments specified, the return of DataFrame.join
always has the left side's index values and name. In the case of how='right'
, there should be np.nan
in the index when the right side does not 'match' a row on the left.
In this case:
>>> pd.DataFrame([], columns=['gene'], index=pd.Index([], name='family')).join(s), how='right', on='gene')
gene gene_id
family
NaN NaN 1
Actual / reproduce
Right index is returned for empty dataframe:
>>> import pandas as pd
>>> s = pd.Series([1], name='gene_id', index=pd.Index([1], name='gene')
>>> pd.DataFrame([], columns=['gene'], index=pd.Index([], name='family')).join(s), how='right', on='gene')
gene gene_id
gene
1 NaN 1
Note that it doesn't happen with non-empty frames:
>>> pd.DataFrame([1], columns=['gene'], index=pd.Index([1], name='family')).join(s), how='right', on='gene')
gene gene_id
family
1 1 1
Version
>>> pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.0.final.0
python-bits: 64
OS: Linux
OS-release: 4.2.5-1-ARCH
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.17.0
nose: None
pip: 7.1.2
setuptools: 18.5
Cython: None
numpy: 1.10.1
scipy: 0.16.1
statsmodels: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: None
numexpr: 2.4.6
matplotlib: 1.5.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.1.0b1
pymysql: None
psycopg2: None