-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Concat with inner join and empty DataFrame #15397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15397 +/- ##
==========================================
- Coverage 90.42% 90.36% -0.06%
==========================================
Files 134 135 +1
Lines 49377 49438 +61
==========================================
+ Hits 44650 44677 +27
- Misses 4727 4761 +34
Continue to review full report at Codecov.
|
doc/source/whatsnew/v0.20.0.txt
Outdated
@@ -580,3 +580,5 @@ Bug Fixes | |||
- Bug in ``Series.replace`` and ``DataFrame.replace`` which failed on empty replacement dicts (:issue:`15289`) | |||
- Bug in ``pd.melt()`` where passing a tuple value for ``value_vars`` caused a ``TypeError`` (:issue:`15348`) | |||
- Bug in ``.eval()`` which caused multiline evals to fail with local variables not on the first line (:issue:`15342`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an FYI, if you put changes in whatsnew NOT at the end (but in empty space that is left), then you won't get conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see. makes sense. thanks!
pandas/tests/tools/test_concat.py
Outdated
@@ -1825,6 +1825,15 @@ def test_concat_bug_3602(self): | |||
result = concat([df1, df2], axis=1) | |||
assert_frame_equal(result, expected) | |||
|
|||
def test_concat_bug_15328(self): | |||
df_empty = pd.DataFrame() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put a comment here for the issue number (rather than in the test name) (try to be descriptive with that if possible)
pandas/tests/tools/test_concat.py
Outdated
df_empty = pd.DataFrame() | ||
df_a = pd.DataFrame({'a': [1, 2]}, index=[0, 1]) | ||
result = pd.concat([df_empty, df_a], axis=1, join='inner') | ||
self.assertTrue(result.empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
construct the result frame and use assert_frame_equal
pandas/tests/tools/test_concat.py
Outdated
self.assertTrue(result.empty) | ||
|
||
result = pd.concat([df_a, df_empty], axis=1, join='inner') | ||
self.assertTrue(result.empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
pandas/tests/tools/test_concat.py
Outdated
|
||
result = pd.concat([df_a, df_empty], axis=1, join='inner') | ||
self.assertTrue(result.empty) | ||
|
||
def test_concat_series_axis1_same_names_ignore_index(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you systematically tests the how=* here? (for the empty cases)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i'm not clear on what you mean here. could you clarify our point to something similar ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what I mean is something like:
for how, expected in [('inner', df_empty), ('outer', df_a), ('left', df_a), ('right', df_empty)]:
result = pd.concat([df_a, df_empty, axis=1, join=how)
assert_frame_equal(result, expected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh haha. got it. thanks!
pandas/tests/tools/test_merge.py
Outdated
df_empty = pd.DataFrame() | ||
df_a = pd.DataFrame({'a': [1, 2]}, index=[0, 1]) | ||
result = pd.merge(df_empty, df_a, left_index=True, right_index=True) | ||
self.assertTrue(result.empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
df_a = pd.DataFrame({'a': [1, 2]}, index=[0, 1], dtype='int64') | ||
df_expected = pd.DataFrame({'a': []}, index=[], dtype='int64') | ||
|
||
for how, expected in [('inner', df_expected), ('outer', df_a)]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right forgot this only accepts outer & inner
thanks @abaldenko ! |
closes pandas-dev#15328 Author: abaldenko <[email protected]> Closes pandas-dev#15397 from abaldenko/concat_empty_dataframe and squashes the following commits: 47c8735 [abaldenko] BUG: Concat with inner join and empty DataFrame fc473b7 [abaldenko] BUG: Concat with inner join and empty DataFrame b86dcb6 [abaldenko] BUG: Concat with inner join and empty DataFrame
git diff upstream/master | flake8 --diff