-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Description
Similar to #4312 and #5702, but this seems specific to object dtype -> new dytpe.
In this first case, we likely convert the whole block, even though we just wanted A.
In [20]: df = pd.DataFrame({"A": [1, 2], "B": [3, 4]}, dtype=object) In [21]: df.dtypes Out[21]: A object B object dtype: object In [22]: df.loc[:, ['A']] = df.loc[:, ['A']].astype(int) In [23]: df.dtypes Out[23]: A int64 B int64 dtype: objectIn this one, (maybe a different bug), we fail to convert ['a', 'b'] to float when they start out in an object block with other values.
In [13]: df = pd.DataFrame([[np.nan, np.nan, 1, pd.Timestamp('2000')]], columns=['a', 'b', 'c', 'd'], dtype=object) In [14]: df.loc[:, ['a', 'b']] = df.loc[:, ['a', 'b']].astype(float) In [15]: df.dtypes Out[15]: a object b object c object d object dtype: objectMetadata
Metadata
Assignees
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves