Skip to content

Commit 47c8735

Browse files
committed
BUG: Concat with inner join and empty DataFrame
1 parent fc473b7 commit 47c8735

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

doc/source/whatsnew/v0.20.0.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ Bug Fixes
570570
- Bug in ``pd.read_csv()`` with ``float_precision='round_trip'`` which caused a segfault when a text entry is parsed (:issue:`15140`)
571571

572572
- Bug in ``DataFrame.to_stata()`` and ``StataWriter`` which produces incorrectly formatted files to be produced for some locales (:issue:`13856`)
573-
573+
- Bug in ``pd.concat()`` in which empty dataframe with ``join='inner'`` was being improperly handled (:issue:`15328`)
574574

575575

576576

@@ -579,6 +579,4 @@ Bug Fixes
579579
- Bug in ``DataFrame.boxplot`` where ``fontsize`` was not applied to the tick labels on both axes (:issue:`15108`)
580580
- Bug in ``Series.replace`` and ``DataFrame.replace`` which failed on empty replacement dicts (:issue:`15289`)
581581
- Bug in ``pd.melt()`` where passing a tuple value for ``value_vars`` caused a ``TypeError`` (:issue:`15348`)
582-
- Bug in ``.eval()`` which caused multiline evals to fail with local variables not on the first line (:issue:`15342`)
583-
584-
- Bug in ``pd.concat()`` in which empty dataframe with ``join='inner'`` was being improperly handled (:issue:`15328`)
582+
- Bug in ``.eval()`` which caused multiline evals to fail with local variables not on the first line (:issue:`15342`)

pandas/tests/tools/test_concat.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1829,12 +1829,11 @@ def test_concat_inner_join_empty(self):
18291829
# GH 15328
18301830
df_empty = pd.DataFrame()
18311831
df_a = pd.DataFrame({'a': [1, 2]}, index=[0, 1], dtype='int64')
1832-
result = pd.concat([df_empty, df_a], axis=1, join='inner')
1833-
expected = pd.DataFrame({'a': []}, index=[], dtype='int64')
1834-
assert_frame_equal(result, expected)
1832+
df_expected = pd.DataFrame({'a': []}, index=[], dtype='int64')
18351833

1836-
result = pd.concat([df_a, df_empty], axis=1, join='inner')
1837-
assert_frame_equal(result, expected)
1834+
for how, expected in [('inner', df_expected), ('outer', df_a)]:
1835+
result = pd.concat([df_a, df_empty], axis=1, join=how)
1836+
assert_frame_equal(result, expected)
18381837

18391838
def test_concat_series_axis1_same_names_ignore_index(self):
18401839
dates = date_range('01-Jan-2013', '01-Jan-2014', freq='MS')[0:-1]

0 commit comments

Comments
 (0)