Skip to content

BUG: Concat with inner join and empty DataFrame #15328

Closed
@jesrael

Description

@jesrael

Function concat with parameter join='inner' not return empty DataFrame:

DF_empty = pd.DataFrame()
DF_a = pd.DataFrame({'a': [1, 2]}, index=[0, 1])
print (DF_empty)
Empty DataFrame
Columns: []
Index: []

print (DF_a)
   a
0  1
1  2

print(pd.concat([DF_empty, DF_a], axis=1, join='inner'))
   a
0  1
1  2

But merge works nice:

print (pd.merge(DF_empty, DF_a, left_index=True, right_index=True))
Empty DataFrame
Columns: [a]
Index: []

SO question


print (pd.show_versions())
INSTALLED VERSIONS ------------------ commit: None python: 3.5.1.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: sk_SK LOCALE: None.None
pandas: 0.19.2
nose: 1.3.7
pip: 9.0.1
setuptools: 20.3
Cython: 0.23.4
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.5.1
pytz: 2016.2
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: 0.2.1
None

<\details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions