Skip to content

BUG: need to block split when filling na #14407

Open
@jreback

Description

@jreback

xref #14400

In [49]: df = pd.DataFrame({'c1' : list('ABC'),
    ...:                            'c2' : list('123'),
    ...:                            'c3' : np.random.randn(3),
    ...:                            'c4' : np.arange(3)})

In [50]: df
Out[50]: 
  c1 c2        c3  c4
0  A  1  0.645628   0
1  B  2 -0.841708   1
2  C  3  0.207423   2

In [51]: df.dtypes
Out[51]: 
c1     object
c2     object
c3    float64
c4      int64
dtype: object

In [52]: df.apply(lambda x: pd.to_numeric(x, errors='coerce')).fillna(df).dtypes
Out[52]: 
c1    object
c2     int64
c3    object
c4     int64
dtype: object

In [53]: df.apply(lambda x: pd.to_numeric(x, errors='coerce')).fillna(df).apply(lambda x: pd.to_numeric(x, errors='ignore')).dtypes
Out[53]: 
c1     object
c2      int64
c3    float64
c4      int64
dtype: object

so [52] should be [53] already, but since the filled block was originally float, I don't think the splitting is happening.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions