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

BUG: unstacking with object columns defaults to None as a fill value #12815

Closed
jreback opened this Issue Apr 6, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@jreback
Contributor

jreback commented Apr 6, 2016

In [41]: df = DataFrame({'A' : [1,1,2], 'B' : list('aba'), 'C' : ['foo', np.nan, 'bar']}).set_index(['A','B'])

In [42]: df.unstack('B')
Out[42]: 
     C      
B    a     b
A           
1  foo   NaN
2  bar  None

In [43]: df.unstack('B', fill_value=np.nan)
Out[43]: 
     C     
B    a    b
A          
1  foo  NaN
2  bar  NaN

Introduced is this PR: #10246

you can make a case to do this as we DO support None as a fill value, but almost always even with object columns we use np.nan, unless very explicity set by the user.

@jreback

This comment has been minimized.

Contributor

jreback commented Apr 6, 2016

@amcpherson

This comment has been minimized.

Contributor

amcpherson commented Apr 12, 2016

So the preferred functionality is?:

In [42]: df.unstack('B')
Out[42]: 
     C      
B    a     b
A           
1  foo  NaN
2  bar  NaN

default to None for object columns seems reasonable to me, but I can fix if np.nan is preferred.

@jreback

This comment has been minimized.

Contributor

jreback commented Apr 12, 2016

yeah we just use nan even for object columns
unless the user is very explicit about it

@jreback jreback modified the milestones: 0.18.1, 0.18.2 Apr 26, 2016

@jorisvandenbossche jorisvandenbossche modified the milestones: Next Major Release, 0.19.0 Aug 21, 2016

@mattayes

This comment has been minimized.

Contributor

mattayes commented Oct 30, 2017

Hey folks, I'm happy to pick this up if no one else is working on it. I'm fairly confident with what needs to change (thanks for linking to the original PR, @jreback).

@amcpherson

This comment has been minimized.

Contributor

amcpherson commented Oct 30, 2017

@mattayes please go ahead.

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 15, 2017

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 15, 2017

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 15, 2017

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 15, 2017

@jreback jreback modified the milestones: Next Major Release, 0.22.0 Nov 15, 2017

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 19, 2017

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 19, 2017

mattayes pushed a commit to mattayes/pandas that referenced this issue Nov 19, 2017

jreback added a commit that referenced this issue Nov 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment