Skip to content

Commit a202f1b

Browse files
committed
Merge branch 'stringdtype2' of github.com:lithomas1/pandas into stringdtype2
2 parents 70be1f6 + b684da0 commit a202f1b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pandas/tests/base/test_misc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pandas._config import using_pyarrow_string_dtype
77

88
from pandas.compat import PYPY
9+
from pandas.compat.numpy import np_version_gt2
910

1011
from pandas.core.dtypes.common import (
1112
is_dtype_equal,
@@ -85,7 +86,7 @@ def test_ndarray_compat_properties(index_or_series_obj):
8586
PYPY or using_pyarrow_string_dtype(),
8687
reason="not relevant for PyPy, doesn't work properly for arrow strings",
8788
)
88-
def test_memory_usage(index_or_series_memory_obj):
89+
def test_memory_usage(index_or_series_memory_obj, request):
8990
obj = index_or_series_memory_obj
9091
# Clear index caches so that len(obj) == 0 report 0 memory usage
9192
if isinstance(obj, Series):
@@ -102,6 +103,14 @@ def test_memory_usage(index_or_series_memory_obj):
102103
is_categorical = isinstance(obj.dtype, pd.CategoricalDtype) or (
103104
is_ser and isinstance(obj.index.dtype, pd.CategoricalDtype)
104105
)
106+
is_object_string = is_dtype_equal(obj, "string[python]") or (
107+
is_ser and is_dtype_equal(obj.index.dtype, "string[python]")
108+
)
109+
if is_object_string and np_version_gt2:
110+
mark = pytest.mark.xfail(
111+
True, reason="NumPy does not expose an API to get StringDType memory usage"
112+
)
113+
request.applymarker(mark)
105114

106115
if len(obj) == 0:
107116
expected = 0

pandas/tests/frame/test_constructors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,12 +3063,12 @@ def test_from_dict_with_columns_na_scalar(self):
30633063
{"a": ["a", "b", "c"], "b": [1.0, 2.0, 3.0], "c": ["d", "e", "f"]},
30643064
],
30653065
)
3066-
def test_np_string_array_object_cast(self, data):
3066+
def test_np_string_array(self, data):
30673067
from numpy.dtypes import StringDType
30683068

30693069
data["a"] = np.array(data["a"], dtype=StringDType())
30703070
res = DataFrame(data)
3071-
assert res["a"].dtype == np.object_
3071+
assert res["a"].dtype == np.dtypes.StringDType()
30723072
assert (res["a"] == data["a"]).all()
30733073

30743074

0 commit comments

Comments
 (0)