Skip to content

Commit ca24177

Browse files
committed
ruff+mypy format
1 parent 645ec56 commit ca24177

File tree

8 files changed

+36
-26
lines changed

8 files changed

+36
-26
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,9 +1612,12 @@ def to_numpy(
16121612
result[~mask] = data[~mask]._pa_array.to_numpy()
16131613
return result
16141614

1615-
def map(self, mapper,
1616-
na_action: Literal["ignore"] | None = None,
1617-
preserve_dtype: bool = False):
1615+
def map(
1616+
self,
1617+
mapper,
1618+
na_action: Literal["ignore"] | None = None,
1619+
preserve_dtype: bool = False,
1620+
):
16181621
if is_numeric_dtype(self.dtype):
16191622
result = map_array(self.to_numpy(), mapper, na_action=na_action)
16201623
if preserve_dtype:

pandas/core/arrays/categorical.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ def map(
15141514
self,
15151515
mapper,
15161516
na_action: Literal["ignore"] | None = None,
1517+
preserve_dtype: bool = True,
15171518
):
15181519
"""
15191520
Map categories using an input mapping or function.
@@ -1535,6 +1536,9 @@ def map(
15351536
If 'ignore', propagate NaN values, without passing them to the
15361537
mapping correspondence.
15371538
1539+
preserve_dtype : bool, default True
1540+
Please safely ignore this parameter.
1541+
15381542
Returns
15391543
-------
15401544
pandas.Categorical or pandas.Index

pandas/core/arrays/datetimelike.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,13 @@ def _unbox(self, other) -> np.int64 | np.datetime64 | np.timedelta64 | np.ndarra
742742
# pandas assumes they're there.
743743

744744
@ravel_compat
745-
def map(self, mapper, na_action: Literal["ignore"] | None = None):
745+
def map(
746+
self,
747+
mapper,
748+
na_action: Literal["ignore"] | None = None,
749+
preserve_type: bool = True,
750+
):
751+
"""Safely ignore the `preserve_type` parameter"""
746752
from pandas import Index
747753

748754
result = map_array(self, mapper, na_action=na_action)

pandas/core/arrays/sparse/array.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,12 @@ def astype(self, dtype: AstypeArg | None = None, copy: bool = True):
13261326

13271327
return self._simple_new(sp_values, self.sp_index, dtype)
13281328

1329-
def map(self, mapper, na_action: Literal["ignore"] | None = None) -> Self:
1329+
def map(
1330+
self,
1331+
mapper,
1332+
na_action: Literal["ignore"] | None = None,
1333+
preserve_dtype: bool = True,
1334+
) -> Self:
13301335
"""
13311336
Map categories using an input mapping or function.
13321337
@@ -1337,6 +1342,8 @@ def map(self, mapper, na_action: Literal["ignore"] | None = None) -> Self:
13371342
na_action : {None, 'ignore'}, default None
13381343
If 'ignore', propagate NA values, without passing them to the
13391344
mapping correspondence.
1345+
preserve_dtype : bool, default True
1346+
Please safely ignore this parameter.
13401347
13411348
Returns
13421349
-------

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4321,7 +4321,7 @@ def nth(self) -> GroupByNthSelector:
43214321
def _nth(
43224322
self,
43234323
n: PositionalIndexer | tuple,
4324-
dropna: Literal["any", "all", None] = None,
4324+
dropna: Literal["any", "all"] | None = None,
43254325
) -> NDFrameT:
43264326
if not dropna:
43274327
mask = self._make_mask_from_positional_indexer(n)

pandas/core/groupby/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def __init__(self, groupby_object: groupby.GroupBy) -> None:
296296
def __call__(
297297
self,
298298
n: PositionalIndexer | tuple,
299-
dropna: Literal["any", "all", None] = None,
299+
dropna: Literal["any", "all"] | None = None,
300300
) -> DataFrame | Series:
301301
return self.groupby_object._nth(n, dropna)
302302

pandas/io/html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def __init__(
220220
attrs: dict[str, str] | None,
221221
encoding: str,
222222
displayed_only: bool,
223-
extract_links: Literal[None, "header", "footer", "body", "all"],
223+
extract_links: Literal["header", "footer", "body", "all"] | None,
224224
storage_options: StorageOptions = None,
225225
) -> None:
226226
self.io = io
@@ -1042,7 +1042,7 @@ def read_html(
10421042
na_values: Iterable[object] | None = None,
10431043
keep_default_na: bool = True,
10441044
displayed_only: bool = True,
1045-
extract_links: Literal[None, "header", "footer", "body", "all"] = None,
1045+
extract_links: Literal["header", "footer", "body", "all"] | None = None,
10461046
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
10471047
storage_options: StorageOptions = None,
10481048
) -> list[DataFrame]:

pandas/tests/frame/test_query_eval.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,13 @@ def test_query_empty_string(self):
160160
df.query("")
161161

162162
def test_query_duplicate_column_name(self, engine, parser):
163-
df = DataFrame(
164-
{
165-
"A": range(3),
166-
"B": range(3),
167-
"C": range(3)
168-
}
169-
).rename(columns={"B": "A"})
163+
df = DataFrame({"A": range(3), "B": range(3), "C": range(3)}).rename(
164+
columns={"B": "A"}
165+
)
170166

171-
res = df.query('C == 1', engine=engine, parser=parser)
167+
res = df.query("C == 1", engine=engine, parser=parser)
172168

173-
expect = DataFrame(
174-
[[1, 1, 1]],
175-
columns=["A", "A", "C"],
176-
index=[1]
177-
)
169+
expect = DataFrame([[1, 1, 1]], columns=["A", "A", "C"], index=[1])
178170

179171
tm.assert_frame_equal(res, expect)
180172

@@ -1140,9 +1132,7 @@ def test_query_with_nested_special_character(self, parser, engine):
11401132
[">=", operator.ge],
11411133
],
11421134
)
1143-
def test_query_lex_compare_strings(
1144-
self, parser, engine, op, func
1145-
):
1135+
def test_query_lex_compare_strings(self, parser, engine, op, func):
11461136
a = Series(np.random.default_rng(2).choice(list("abcde"), 20))
11471137
b = Series(np.arange(a.size))
11481138
df = DataFrame({"X": a, "Y": b})
@@ -1411,7 +1401,7 @@ def test_expr_with_column_name_with_backtick_and_hash(self):
14111401
def test_expr_with_column_name_with_backtick(self):
14121402
# GH 59285
14131403
df = DataFrame({"a`b": (1, 2, 3), "ab": (4, 5, 6)})
1414-
result = df.query("`a``b` < 2") # noqa
1404+
result = df.query("`a``b` < 2")
14151405
# Note: Formatting checks may wrongly consider the above ``inline code``.
14161406
expected = df[df["a`b"] < 2]
14171407
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)