Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

abaldenko
Copy link
Contributor

@abaldenko abaldenko commented Feb 14, 2017

@codecov-io
Copy link

codecov-io commented Feb 14, 2017

Codecov Report

Merging #15397 into master will decrease coverage by -0.06%.
The diff coverage is n/a.

@@            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
Impacted Files Coverage Δ
pandas/tools/concat.py 97.62% <ø> (ø)
pandas/io/s3.py 0% <ø> (-85%)
pandas/util/testing.py 81.97% <ø> (-1.41%)
pandas/io/common.py 70% <ø> (-0.87%)
pandas/io/html.py 84.48% <ø> (-0.67%)
pandas/core/groupby.py 94.89% <ø> (-0.24%)
pandas/io/excel.py 79.39% <ø> (-0.16%)
pandas/core/algorithms.py 94.47% <ø> (-0.01%)
pandas/core/reshape.py 99.25% <ø> (-0.01%)
pandas/stats/moments.py 71.19% <ø> (ø)
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff0deec...47c8735. Read the comment docs.

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Feb 14, 2017
@@ -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`)
Copy link
Contributor

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.

Copy link
Contributor Author

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!

@@ -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()
Copy link
Contributor

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)

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)
Copy link
Contributor

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

self.assertTrue(result.empty)

result = pd.concat([df_a, df_empty], axis=1, join='inner')
self.assertTrue(result.empty)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


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):
Copy link
Contributor

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)

Copy link
Contributor Author

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 ?

Copy link
Contributor

@jreback jreback Feb 14, 2017

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)

Copy link
Contributor Author

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!

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)
Copy link
Contributor

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)]:
Copy link
Contributor

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

@jreback jreback added this to the 0.20.0 milestone Feb 16, 2017
@jreback
Copy link
Contributor

jreback commented Feb 16, 2017

thanks @abaldenko !

@jreback jreback closed this in c7300ea Feb 16, 2017
AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this pull request Mar 21, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Concat with inner join and empty DataFrame
3 participants