Skip to content

Commit 296a9df

Browse files
committed
style updates
1 parent 2415e46 commit 296a9df

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

pandas/core/frame.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
)
9696
from pandas.core.dtypes.missing import isna, notna
9797

98-
from pandas._typing import Axis, Axes, Dtype, FilePathOrBuffer, Level
98+
from pandas._typing import Axes, Axis, Dtype, FilePathOrBuffer, Level
9999
from pandas.core import algorithms, common as com, nanops, ops
100100
from pandas.core.accessor import CachedAccessor
101101
from pandas.core.arrays import Categorical, ExtensionArray
@@ -2076,7 +2076,7 @@ def to_stata(
20762076
data_label=data_label,
20772077
write_index=write_index,
20782078
variable_labels=variable_labels,
2079-
**kwargs
2079+
**kwargs,
20802080
)
20812081
writer.write_file()
20822082

@@ -2102,7 +2102,7 @@ def to_parquet(
21022102
compression="snappy",
21032103
index=None,
21042104
partition_cols=None,
2105-
**kwargs
2105+
**kwargs,
21062106
):
21072107
"""
21082108
Write a DataFrame to the binary parquet format.
@@ -2182,7 +2182,7 @@ def to_parquet(
21822182
compression=compression,
21832183
index=index,
21842184
partition_cols=partition_cols,
2185-
**kwargs
2185+
**kwargs,
21862186
)
21872187

21882188
@Substitution(
@@ -4038,7 +4038,7 @@ def rename(
40384038
mapper: Optional[
40394039
Union[Mapping[Hashable, Hashable], Callable[[Hashable], Hashable]]
40404040
] = None,
4041-
*,
4041+
*,
40424042
index: Optional[
40434043
Union[Mapping[Hashable, Hashable], Callable[[Hashable], Hashable]]
40444044
] = None,
@@ -4160,8 +4160,16 @@ def rename(
41604160
2 2 5
41614161
4 3 6
41624162
"""
4163-
return super().rename(mapper=mapper, index=index, columns=columns, axis=axis, copy=copy,
4164-
inplace=inplace, level=level, errors=errors)
4163+
return super().rename(
4164+
mapper=mapper,
4165+
index=index,
4166+
columns=columns,
4167+
axis=axis,
4168+
copy=copy,
4169+
inplace=inplace,
4170+
level=level,
4171+
errors=errors,
4172+
)
41654173

41664174
@Substitution(**_shared_doc_kwargs)
41674175
@Appender(NDFrame.fillna.__doc__)
@@ -4173,7 +4181,7 @@ def fillna(
41734181
inplace=False,
41744182
limit=None,
41754183
downcast=None,
4176-
**kwargs
4184+
**kwargs,
41774185
):
41784186
return super().fillna(
41794187
value=value,
@@ -4182,7 +4190,7 @@ def fillna(
41824190
inplace=inplace,
41834191
limit=limit,
41844192
downcast=downcast,
4185-
**kwargs
4193+
**kwargs,
41864194
)
41874195

41884196
@Appender(_shared_docs["replace"] % _shared_doc_kwargs)
@@ -6629,7 +6637,7 @@ def _gotitem(
66296637
see_also=_agg_summary_and_see_also_doc,
66306638
examples=_agg_examples_doc,
66316639
versionadded="\n.. versionadded:: 0.20.0\n",
6632-
**_shared_doc_kwargs
6640+
**_shared_doc_kwargs,
66336641
)
66346642
@Appender(_shared_docs["aggregate"])
66356643
def aggregate(self, func, axis=0, *args, **kwargs):

pandas/core/generic.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ def rename(
10191019
mapper: Optional[
10201020
Union[Mapping[Hashable, Hashable], Callable[[Hashable], Hashable]]
10211021
] = None,
1022-
*,
1022+
*,
10231023
index: Optional[
10241024
Union[Mapping[Hashable, Hashable], Callable[[Hashable], Hashable]]
10251025
] = None,
@@ -1147,11 +1147,15 @@ def rename(
11471147
if mapper is None and index is None and columns is None:
11481148
raise TypeError("must pass an index to rename")
11491149

1150-
if (index is not None or columns is not None):
1150+
if index is not None or columns is not None:
11511151
if axis is not None:
1152-
raise TypeError("Cannot specify both 'axis' and any of 'index' or 'columns'")
1152+
raise TypeError(
1153+
"Cannot specify both 'axis' and any of 'index' or 'columns'"
1154+
)
11531155
elif mapper is not None:
1154-
raise TypeError("Cannot specify both 'mapper' and any of 'index' or 'columns'")
1156+
raise TypeError(
1157+
"Cannot specify both 'mapper' and any of 'index' or 'columns'"
1158+
)
11551159
else:
11561160
# use the mapper argument
11571161
if axis in {1, "columns"}:
@@ -1166,7 +1170,7 @@ def rename(
11661170
continue
11671171

11681172
axis = self._get_axis(axis_no)
1169-
baxis = self._get_block_manager_axis(axis_no)
1173+
baxis = self._get_block_manager_axis(axis_no)
11701174
f = com.get_rename_function(replacements)
11711175

11721176
if level is not None:
@@ -1177,7 +1181,9 @@ def rename(
11771181
indexer = axis.get_indexer_for(replacements)
11781182
if errors == "raise" and len(indexer[indexer == -1]):
11791183
missing_labels = [
1180-
label for index, label in enumerate(replacements) if indexer[index] == -1
1184+
label
1185+
for index, label in enumerate(replacements)
1186+
if indexer[index] == -1
11811187
]
11821188
raise KeyError("{} not found in axis".format(missing_labels))
11831189

@@ -7030,7 +7036,7 @@ def interpolate(
70307036
limit_direction="forward",
70317037
limit_area=None,
70327038
downcast=None,
7033-
**kwargs
7039+
**kwargs,
70347040
):
70357041
"""
70367042
Interpolate values according to different methods.
@@ -7103,7 +7109,7 @@ def interpolate(
71037109
limit_area=limit_area,
71047110
inplace=inplace,
71057111
downcast=downcast,
7106-
**kwargs
7112+
**kwargs,
71077113
)
71087114

71097115
if inplace:
@@ -7803,7 +7809,7 @@ def groupby(
78037809
group_keys=True,
78047810
squeeze=False,
78057811
observed=False,
7806-
**kwargs
7812+
**kwargs,
78077813
):
78087814
"""
78097815
Group DataFrame or Series using a mapper or by a Series of columns.
@@ -7929,7 +7935,7 @@ def groupby(
79297935
group_keys=group_keys,
79307936
squeeze=squeeze,
79317937
observed=observed,
7932-
**kwargs
7938+
**kwargs,
79337939
)
79347940

79357941
def asfreq(self, freq, method=None, how=None, normalize=False, fill_value=None):
@@ -11570,7 +11576,7 @@ def stat_func(
1157011576
level=None,
1157111577
numeric_only=None,
1157211578
min_count=0,
11573-
**kwargs
11579+
**kwargs,
1157411580
):
1157511581
if name == "sum":
1157611582
nv.validate_sum(tuple(), kwargs)

pandas/core/series.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
)
5454

5555
import pandas as pd
56+
from pandas._typing import Axis, Level
5657
from pandas.core import algorithms, base, generic, nanops, ops
5758
from pandas.core.accessor import CachedAccessor
5859
from pandas.core.arrays import ExtensionArray
@@ -78,7 +79,6 @@
7879
from pandas.core.strings import StringMethods
7980
from pandas.core.tools.datetimes import to_datetime
8081

81-
from pandas._typing import Axis, Level
8282
import pandas.io.formats.format as fmt
8383
import pandas.plotting
8484

@@ -4085,12 +4085,12 @@ def rename(
40854085
index: Optional[
40864086
Union[Hashable, Mapping[Hashable, Hashable], Callable[[Hashable], Hashable]]
40874087
] = None,
4088-
*,
4089-
axis: Optional[Axis] = None,
4088+
*,
4089+
axis: Optional[Axis] = None,
40904090
copy: bool = True,
40914091
inplace: bool = False,
40924092
level: Optional[Level] = None,
4093-
errors: str = "ignore"
4093+
errors: str = "ignore"
40944094
) -> "Series":
40954095
"""
40964096
Alter Series index labels or name.
@@ -4156,7 +4156,9 @@ def rename(
41564156
dtype: int64
41574157
"""
41584158
if callable(index) or is_dict_like(index):
4159-
return super().rename(index, copy=copy, inplace=inplace, level=level, errors=errors)
4159+
return super().rename(
4160+
index, copy=copy, inplace=inplace, level=level, errors=errors
4161+
)
41604162
else:
41614163
return self._set_name(index, inplace=inplace)
41624164

pandas/tests/frame/test_alter_axes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ def test_rename_no_mappings_raises(self):
13791379
df.rename(None, columns=None)
13801380

13811381
with pytest.raises(TypeError, match=msg):
1382-
df.rename(None, columns=None, index=None)
1382+
df.rename(None, columns=None, index=None)
13831383

13841384
def test_rename_mapper_and_positional_arguments_raises(self):
13851385
# GH 29136

0 commit comments

Comments
 (0)