Skip to content

BUG: applymap on empty DataFrame returns Series (#8222) #14977

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

Merged
merged 1 commit into from
Dec 24, 2016

Conversation

mroeschke
Copy link
Member

Within applymap, the data is converted into a numpy array with asobject here and evaluated with the apply method _apply_empty_result since this frame is empty. The numpy array is compared to an Series here which proceeds to get returned as a Series here.

Found that passing in the data without using asobject allows the logic to return a copy of the empty dataframe here.

@codecov-io
Copy link

codecov-io commented Dec 24, 2016

Current coverage is 84.65% (diff: 100%)

Merging #14977 into master will increase coverage by <.01%

@@             master     #14977   diff @@
==========================================
  Files           144        144          
  Lines         51047      51049     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43216      43218     +2   
  Misses         7831       7831          
  Partials          0          0          

Powered by Codecov. Last update d7e8f31...255db8e

@jreback jreback added the Testing pandas testing functions or related to the test suite label Dec 24, 2016
@@ -284,7 +284,7 @@ Bug Fixes
- Bug in ``DataFrame(..).apply(to_numeric)`` when values are of type decimal.Decimal. (:issue:`14827`)
- Bug in ``describe()`` when passing a numpy array which does not contain the median to the ``percentiles`` keyword argument (:issue:`14908`)
- Bug in ``DataFrame.sort_values()`` when sorting by multiple columns where one column is of type ``int64`` and contains ``NaT`` (:issue:`14922`)

- Bug in ``applymap()`` returning a ``Series`` with an empty ``DataFrame`` (:issue:`8222`)
Copy link
Contributor

Choose a reason for hiding this comment

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

move to API changes

# GH 8222
empty_frames = [pd.DataFrame(),
pd.DataFrame(columns=list('ABC')),
pd.DataFrame(index=list('ABC'))]
Copy link
Contributor

Choose a reason for hiding this comment

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

add one with data as well

@jreback jreback added API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode and removed Testing pandas testing functions or related to the test suite labels Dec 24, 2016
fix whatsnew file

Adjust whatsnew to API change and add test with data
@mroeschke
Copy link
Member Author

Changes made and all green. Thanks!

@jreback jreback added this to the 0.20.0 milestone Dec 24, 2016
@jreback jreback merged commit e73e845 into pandas-dev:master Dec 24, 2016
@jreback
Copy link
Contributor

jreback commented Dec 24, 2016

thanks!

ShaharBental pushed a commit to ShaharBental/pandas that referenced this pull request Dec 26, 2016
…ndas-dev#14977)

fix whatsnew file

Adjust whatsnew to API change and add test with data
@mroeschke mroeschke deleted the fix_8222 branch December 20, 2017 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: applymap on empty DataFrame returns Series
3 participants