Skip to content

Commit

Permalink
moved test case to frame and serier folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Anurag-Varma committed Feb 18, 2025
1 parent 3d40bca commit 43e97c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,8 @@ Conversion
- Bug in :meth:`DataFrame.astype` not casting ``values`` for Arrow-based dictionary dtype correctly (:issue:`58479`)
- Bug in :meth:`DataFrame.update` bool dtype being converted to object (:issue:`55509`)
- Bug in :meth:`Series.astype` might modify read-only array inplace when casting to a string dtype (:issue:`57212`)
- Bug in :meth:`Series.reindex` not maintaining ``float32`` type when a ``reindex`` introduces a missing value (:issue:`45857`)
- Bug in :meth:`Series.convert_dtypes` and :meth:`DataFrame.convert_dtypes` removing timezone information for objects with :class:`ArrowDtype` (:issue:`60237`)
- Bug in :meth:`Series.reindex` not maintaining ``float32`` type when a ``reindex`` introduces a missing value (:issue:`45857`)

Strings
^^^^^^^
Expand Down
24 changes: 0 additions & 24 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3511,27 +3511,3 @@ def test_map_numeric_na_action():
result = ser.map(lambda x: 42, na_action="ignore")
expected = pd.Series([42.0, 42.0, np.nan], dtype="float64")
tm.assert_series_equal(result, expected)


def test_convert_dtype_pyarrow_timezone_preserve():
# GH 60237
pytest.importorskip("pyarrow")
ser = pd.Series(
pd.to_datetime(range(5), utc=True, unit="h"),
dtype="timestamp[ns, tz=UTC][pyarrow]",
)
result = ser.convert_dtypes(dtype_backend="pyarrow")
expected = ser.copy()
tm.assert_series_equal(result, expected)

df = pd.DataFrame(
{
"timestamps": pd.Series(
pd.to_datetime(range(5), utc=True, unit="h"),
dtype="timestamp[ns, tz=UTC][pyarrow]",
)
}
)
result = df.convert_dtypes(dtype_backend="pyarrow")
expected = df.copy()
tm.assert_frame_equal(result, expected)
14 changes: 14 additions & 0 deletions pandas/tests/frame/methods/test_convert_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,17 @@ def test_convert_dtypes_from_arrow(self):
result = df.convert_dtypes()
expected = df.astype({"a": "string[python]"})
tm.assert_frame_equal(result, expected)

def test_convert_dtype_pyarrow_timezone_preserve(self):
# GH 60237
df = pd.DataFrame(
{
"timestamps": pd.Series(
pd.to_datetime(range(5), utc=True, unit="h"),
dtype="timestamp[ns, tz=UTC][pyarrow]",
)
}
)
result = df.convert_dtypes(dtype_backend="pyarrow")
expected = df.copy()
tm.assert_frame_equal(result, expected)
11 changes: 11 additions & 0 deletions pandas/tests/series/methods/test_convert_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,14 @@ def test_convert_dtypes_pyarrow_null(self):
result = ser.convert_dtypes(dtype_backend="pyarrow")
expected = pd.Series([None, None], dtype=pd.ArrowDtype(pa.null()))
tm.assert_series_equal(result, expected)

def test_convert_dtype_pyarrow_timezone_preserve(self):
# GH 60237
pytest.importorskip("pyarrow")
ser = pd.Series(
pd.to_datetime(range(5), utc=True, unit="h"),
dtype="timestamp[ns, tz=UTC][pyarrow]",
)
result = ser.convert_dtypes(dtype_backend="pyarrow")
expected = ser.copy()
tm.assert_series_equal(result, expected)

0 comments on commit 43e97c5

Please sign in to comment.