Skip to content

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

Closed
@jreback

Description

@jreback
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions