Skip to content

Commit f71cd9a

Browse files
TomAugspurgerjreback
authored andcommitted
BUG: Allow overwriting object columns with EAs (#20556)
Closes #20555
1 parent 14f03ce commit f71cd9a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pandas/core/internals.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,10 @@ def should_store(self, value):
23792379
return not (issubclass(value.dtype.type,
23802380
(np.integer, np.floating, np.complexfloating,
23812381
np.datetime64, np.bool_)) or
2382-
is_extension_type(value))
2382+
# TODO(ExtensionArray): remove is_extension_type
2383+
# when all extension arrays have been ported.
2384+
is_extension_type(value) or
2385+
is_extension_array_dtype(value))
23832386

23842387
def replace(self, to_replace, value, inplace=False, filter=None,
23852388
regex=False, convert=True, mgr=None):

pandas/tests/extension/base/reshaping.py

+6
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ def test_set_frame_expand_extension_with_regular(self, data):
7575
df['B'] = [1] * len(data)
7676
expected = pd.DataFrame({"A": data, "B": [1] * len(data)})
7777
self.assert_frame_equal(df, expected)
78+
79+
def test_set_frame_overwrite_object(self, data):
80+
# https://github.com/pandas-dev/pandas/issues/20555
81+
df = pd.DataFrame({"A": [1] * len(data)}, dtype=object)
82+
df['A'] = data
83+
assert df.dtypes['A'] == data.dtype

0 commit comments

Comments
 (0)