Skip to content

Commit d1da8c8

Browse files
committed
Changes according to comments
1 parent 82dc446 commit d1da8c8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

pandas/core/internals/construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def init_dict(data, index, columns, dtype=None):
242242

243243
# no obvious "empty" int column
244244
if missing.any() and not is_integer_dtype(dtype):
245-
if is_dtype_equal(dtype, "string"):
245+
if is_extension_array_dtype(dtype):
246246
# GH 33623
247247
nan_dtype = dtype
248248
elif dtype is None or np.issubdtype(dtype, np.flexible):

pandas/tests/extension/test_common.py

+6
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ def test_astype_no_copy():
7979
def test_is_extension_array_dtype(dtype):
8080
assert isinstance(dtype, dtypes.ExtensionDtype)
8181
assert is_extension_array_dtype(dtype)
82+
83+
84+
@pytest.mark.parametrize("columns, dtype", [(["a"], "string")])
85+
def test_construct_empty_dataframe_with_string_dtype(columns, dtype):
86+
# GH 33623
87+
pd.DataFrame(columns=columns, dtype=dtype)

pandas/tests/frame/test_constructors.py

-4
Original file line numberDiff line numberDiff line change
@@ -2679,7 +2679,3 @@ def test_construction_from_set_raises(self):
26792679
msg = "Set type is unordered"
26802680
with pytest.raises(TypeError, match=msg):
26812681
pd.DataFrame({"a": {1, 2, 3}})
2682-
2683-
def test_construct_empty_dataframe_with_string_dtype(self):
2684-
# GH 33623
2685-
pd.DataFrame(columns=["a"], dtype="string")

0 commit comments

Comments
 (0)