Skip to content

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

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
jreback opened this issue Apr 6, 2016 · 5 comments · Fixed by #18313
Closed

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

jreback opened this issue Apr 6, 2016 · 5 comments · Fixed by #18313
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@jreback
Copy link
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 jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Difficulty Intermediate labels Apr 6, 2016
@jreback jreback added this to the 0.18.1 milestone Apr 6, 2016
@jreback
Copy link
Contributor Author

jreback commented Apr 6, 2016

cc @amcpherson

@amcpherson
Copy link
Contributor

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

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

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

@mattayes please go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants