Skip to content

Commit 76a0452

Browse files
committed
changing test location to test_covert_dtypes.py
1 parent 16e727f commit 76a0452

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

pandas/core/dtypes/dtypes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,9 @@ def name(self) -> str: # type: ignore[override]
22772277
@cache_readonly
22782278
def numpy_dtype(self) -> np.dtype:
22792279
"""Return an instance of the related numpy dtype"""
2280+
if pa.types.is_string(self.pyarrow_dtype):
2281+
# pa.string().to_pandas_dtype() = object which we don't want
2282+
return np.dtype(str)
22802283
try:
22812284
return np.dtype(self.pyarrow_dtype.to_pandas_dtype())
22822285
except (NotImplementedError, TypeError):

pandas/tests/copy_view/test_astype.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,3 @@ def test_convert_dtypes(using_infer_string):
236236
df2.iloc[0, 0] = "x"
237237
df2.iloc[0, 1] = 10
238238
tm.assert_frame_equal(df, df_orig)
239-
240-
241-
def test_convert_dtypes_pyarrow_timezone():
242-
# GH 60237
243-
expected = Series(
244-
[
245-
"1970-01-01 00:00:00+00:00",
246-
"1970-01-01 01:00:00+00:00",
247-
"1970-01-01 02:00:00+00:00",
248-
"1970-01-01 03:00:00+00:00",
249-
"1970-01-01 04:00:00+00:00",
250-
],
251-
dtype="timestamp[ns, tz=UTC][pyarrow]",
252-
)
253-
result = expected.convert_dtypes(dtype_backend="pyarrow")
254-
tm.assert_series_equal(result, expected)

pandas/tests/frame/methods/test_convert_dtypes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,12 @@ def test_convert_dtypes_from_arrow(self):
196196
result = df.convert_dtypes()
197197
expected = df.astype({"a": "string[python]"})
198198
tm.assert_frame_equal(result, expected)
199+
200+
def test_convert_dtypes_timezone_series(self):
201+
df = pd.Series(
202+
pd.to_datetime(range(5), utc=True, unit="h"),
203+
dtype="timestamp[ns, tz=UTC][pyarrow]",
204+
)
205+
result = df.convert_dtypes(dtype_backend="pyarrow")
206+
expected = df
207+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)