Skip to content
Prev Previous commit
Next Next commit
Apply Ruff and Ruff-format auto-fixes
  • Loading branch information
pedromfdiogo committed May 19, 2025
commit d845306ebc33519edc81934f736910c8dd91d207
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 @@ -811,11 +811,11 @@ ExtensionArray
- Bug in :class:`Categorical` when constructing with an :class:`Index` with :class:`ArrowDtype` (:issue:`60563`)
- Bug in :meth:`.arrays.ArrowExtensionArray.__setitem__` which caused wrong behavior when using an integer array with repeated values as a key (:issue:`58530`)
- Bug in :meth:`ArrowExtensionArray.factorize` where NA values were dropped when input was dictionary-encoded even when dropna was set to False(:issue:`60567`)
- Bug in :meth:`Series.map` and :meth:`Series.apply` where applying functions to a Series with an :class:`Int32Dtype` or other :class:`ExtensionDtype` would convert elements to float and ``pd.NA`` to ``np.nan``, instead of preserving the original types (:issue:`60766`)
- Bug in :meth:`api.types.is_datetime64_any_dtype` where a custom :class:`ExtensionDtype` would return ``False`` for array-likes (:issue:`57055`)
- Bug in comparison between object with :class:`ArrowDtype` and incompatible-dtyped (e.g. string vs bool) incorrectly raising instead of returning all-``False`` (for ``==``) or all-``True`` (for ``!=``) (:issue:`59505`)
- Bug in constructing pandas data structures when passing into ``dtype`` a string of the type followed by ``[pyarrow]`` while PyArrow is not installed would raise ``NameError`` rather than ``ImportError`` (:issue:`57928`)
- Bug in various :class:`DataFrame` reductions for pyarrow temporal dtypes returning incorrect dtype when result was null (:issue:`59234`)
- Bug in :meth:`Series.map` and :meth:`Series.apply` where applying functions to a Series with an :class:`Int32Dtype` or other :class:`ExtensionDtype` would convert elements to float and ``pd.NA`` to ``np.nan``, instead of preserving the original types (:issue:`60766`)


Styler
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/arrays/masked/test_basemaskedarray_map.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import pandas as pd


def test_basemaskedarray_map():
for dtype, data, expected_data in [
("Int32", [1, 2, None, 4], [2, 3, pd.NA, 5]),

("Int32", [1, 2, None, 4], [2, 3, pd.NA, 5]),
]:
s = pd.Series(data, dtype=dtype)

def transform(x):
if x is None:
if x is None:
return x
return x + 1

result = s.map(transform)
expected = pd.Series(expected_data, dtype=result.dtype)
expected = pd.Series(expected_data, dtype=result.dtype)

assert result.tolist() == expected.tolist()
4 changes: 2 additions & 2 deletions pandas/tests/extension/test_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_map(self, data_missing, na_action):
if result[i] is pd.NA:
result[i] = "nan"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt this pretty unwanted behavior?

result = result.astype("float64")

if data_missing.dtype == Float32Dtype():
# map roundtrips through objects, which converts to float64
expected = data_missing.to_numpy(dtype="float64", na_value=np.nan)
Expand All @@ -187,7 +187,7 @@ def test_map(self, data_missing, na_action):
def test_map_na_action_ignore(self, data_missing_for_sorting):
zero = data_missing_for_sorting[2]
result = data_missing_for_sorting.map(lambda x: zero, na_action="ignore")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to avoid this unrelated changes

if data_missing_for_sorting.dtype.kind == "b":
expected = np.array([False, pd.NA, False], dtype=object)
else:
Expand Down
Loading