BUG: change dtype of Series from non-object to object inplace · Issue #3217 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@jreback

Description

@jreback

see also #3216 , #3386

test in tests/test_series.py (test_update)

but cannot be fixed until Series is not longer a ndarray sub-class
as numpy cannot handle the float64 to object in-place dtype conversion
(which is why the sub-class issue comes up), if we have a single block
then can just swap out the block rather than attempting numpy magic here

In [18]: df = pd.DataFrame([{"a": 1}, {"a": 3, "b": 2}])
In [19]: df['c'] = np.nan
In [20]: df['c'].update(pd.Series(['foo'],index=[0]))
TypeError: Cannot change data-type for object array.