Skip to content

Commit fe98274

Browse files
MarcoGorelliKevin D Smith
authored and
Kevin D Smith
committed
CLN remove unnecessary trailing commas to get ready for new version of black: generic -> blocks (pandas-dev#35950)
* pandas/core/groupby/generic.py * pandas/core/groupby/groupby.py * pandas/core/groupby/ops.py * pandas/core/indexes/datetimelike.py * pandas/core/indexes/interval.py * pandas/core/indexes/numeric.py * pandas/core/indexes/range.py * pandas/core/internals/blocks.py
1 parent 631f0b2 commit fe98274

File tree

8 files changed

+29
-43
lines changed

8 files changed

+29
-43
lines changed

pandas/core/groupby/generic.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ def _selection_name(self):
221221
def apply(self, func, *args, **kwargs):
222222
return super().apply(func, *args, **kwargs)
223223

224-
@doc(
225-
_agg_template, examples=_agg_examples_doc, klass="Series",
226-
)
224+
@doc(_agg_template, examples=_agg_examples_doc, klass="Series")
227225
def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs):
228226

229227
if maybe_use_numba(engine):
@@ -935,9 +933,7 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
935933
See :ref:`groupby.aggregate.named` for more."""
936934
)
937935

938-
@doc(
939-
_agg_template, examples=_agg_examples_doc, klass="DataFrame",
940-
)
936+
@doc(_agg_template, examples=_agg_examples_doc, klass="DataFrame")
941937
def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs):
942938

943939
if maybe_use_numba(engine):

pandas/core/groupby/groupby.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def _aggregate_with_numba(self, data, func, *args, engine_kwargs=None, **kwargs)
10771077
tuple(args), kwargs, func, engine_kwargs
10781078
)
10791079
result = numba_agg_func(
1080-
sorted_data, sorted_index, starts, ends, len(group_keys), len(data.columns),
1080+
sorted_data, sorted_index, starts, ends, len(group_keys), len(data.columns)
10811081
)
10821082
if cache_key not in NUMBA_FUNC_CACHE:
10831083
NUMBA_FUNC_CACHE[cache_key] = numba_agg_func
@@ -1595,8 +1595,7 @@ def max(self, numeric_only: bool = False, min_count: int = -1):
15951595
def first(self, numeric_only: bool = False, min_count: int = -1):
15961596
def first_compat(obj: FrameOrSeries, axis: int = 0):
15971597
def first(x: Series):
1598-
"""Helper function for first item that isn't NA.
1599-
"""
1598+
"""Helper function for first item that isn't NA."""
16001599
x = x.array[notna(x.array)]
16011600
if len(x) == 0:
16021601
return np.nan
@@ -1620,8 +1619,7 @@ def first(x: Series):
16201619
def last(self, numeric_only: bool = False, min_count: int = -1):
16211620
def last_compat(obj: FrameOrSeries, axis: int = 0):
16221621
def last(x: Series):
1623-
"""Helper function for last item that isn't NA.
1624-
"""
1622+
"""Helper function for last item that isn't NA."""
16251623
x = x.array[notna(x.array)]
16261624
if len(x) == 0:
16271625
return np.nan

pandas/core/groupby/ops.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def transform(self, values, how: str, axis: int = 0, **kwargs):
583583
return self._cython_operation("transform", values, how, axis, **kwargs)
584584

585585
def _aggregate(
586-
self, result, counts, values, comp_ids, agg_func, min_count: int = -1,
586+
self, result, counts, values, comp_ids, agg_func, min_count: int = -1
587587
):
588588
if agg_func is libgroupby.group_nth:
589589
# different signature from the others
@@ -603,9 +603,7 @@ def _transform(
603603

604604
return result
605605

606-
def agg_series(
607-
self, obj: Series, func: F, *args, **kwargs,
608-
):
606+
def agg_series(self, obj: Series, func: F, *args, **kwargs):
609607
# Caller is responsible for checking ngroups != 0
610608
assert self.ngroups != 0
611609

@@ -653,9 +651,7 @@ def _aggregate_series_fast(self, obj: Series, func: F):
653651
result, counts = grouper.get_result()
654652
return result, counts
655653

656-
def _aggregate_series_pure_python(
657-
self, obj: Series, func: F, *args, **kwargs,
658-
):
654+
def _aggregate_series_pure_python(self, obj: Series, func: F, *args, **kwargs):
659655
group_index, _, ngroups = self.group_info
660656

661657
counts = np.zeros(ngroups, dtype=int)
@@ -841,9 +837,7 @@ def groupings(self) -> "List[grouper.Grouping]":
841837
for lvl, name in zip(self.levels, self.names)
842838
]
843839

844-
def agg_series(
845-
self, obj: Series, func: F, *args, **kwargs,
846-
):
840+
def agg_series(self, obj: Series, func: F, *args, **kwargs):
847841
# Caller is responsible for checking ngroups != 0
848842
assert self.ngroups != 0
849843
assert len(self.bins) > 0 # otherwise we'd get IndexError in get_result

pandas/core/indexes/datetimelike.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ def wrapper(left, right):
8181
DatetimeLikeArrayMixin,
8282
cache=True,
8383
)
84-
@inherit_names(
85-
["mean", "asi8", "freq", "freqstr", "_box_func"], DatetimeLikeArrayMixin,
86-
)
84+
@inherit_names(["mean", "asi8", "freq", "freqstr", "_box_func"], DatetimeLikeArrayMixin)
8785
class DatetimeIndexOpsMixin(ExtensionIndex):
8886
"""
8987
Common ops mixin to support a unified interface datetimelike Index.

pandas/core/indexes/interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ def func(intvidx_self, other, sort=False):
182182
)
183183
@inherit_names(["set_closed", "to_tuples"], IntervalArray, wrap=True)
184184
@inherit_names(
185-
["__array__", "overlaps", "contains", "left", "right", "length"], IntervalArray,
185+
["__array__", "overlaps", "contains", "left", "right", "length"], IntervalArray
186186
)
187187
@inherit_names(
188-
["is_non_overlapping_monotonic", "mid", "closed"], IntervalArray, cache=True,
188+
["is_non_overlapping_monotonic", "mid", "closed"], IntervalArray, cache=True
189189
)
190190
class IntervalIndex(IntervalMixin, ExtensionIndex):
191191
_typ = "intervalindex"

pandas/core/indexes/numeric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def isin(self, values, level=None):
436436
def _is_compatible_with_other(self, other) -> bool:
437437
return super()._is_compatible_with_other(other) or all(
438438
isinstance(
439-
obj, (ABCInt64Index, ABCFloat64Index, ABCUInt64Index, ABCRangeIndex),
439+
obj, (ABCInt64Index, ABCFloat64Index, ABCUInt64Index, ABCRangeIndex)
440440
)
441441
for obj in [self, other]
442442
)

pandas/core/indexes/range.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class RangeIndex(Int64Index):
8282
# Constructors
8383

8484
def __new__(
85-
cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None,
85+
cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None
8686
):
8787

8888
cls._validate_dtype(dtype)

pandas/core/internals/blocks.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def replace(
724724
# _can_hold_element checks have reduced this back to the
725725
# scalar case and we can avoid a costly object cast
726726
return self.replace(
727-
to_replace[0], value, inplace=inplace, regex=regex, convert=convert,
727+
to_replace[0], value, inplace=inplace, regex=regex, convert=convert
728728
)
729729

730730
# GH 22083, TypeError or ValueError occurred within error handling
@@ -905,7 +905,7 @@ def setitem(self, indexer, value):
905905
return block
906906

907907
def putmask(
908-
self, mask, new, inplace: bool = False, axis: int = 0, transpose: bool = False,
908+
self, mask, new, inplace: bool = False, axis: int = 0, transpose: bool = False
909909
) -> List["Block"]:
910910
"""
911911
putmask the data to the block; it is possible that we may create a
@@ -1292,7 +1292,7 @@ def shift(self, periods: int, axis: int = 0, fill_value=None):
12921292
return [self.make_block(new_values)]
12931293

12941294
def where(
1295-
self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0,
1295+
self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0
12961296
) -> List["Block"]:
12971297
"""
12981298
evaluate the block; return result block(s) from the result
@@ -1366,7 +1366,7 @@ def where_func(cond, values, other):
13661366
# we are explicitly ignoring errors
13671367
block = self.coerce_to_target_dtype(other)
13681368
blocks = block.where(
1369-
orig_other, cond, errors=errors, try_cast=try_cast, axis=axis,
1369+
orig_other, cond, errors=errors, try_cast=try_cast, axis=axis
13701370
)
13711371
return self._maybe_downcast(blocks, "infer")
13721372

@@ -1605,7 +1605,7 @@ def set(self, locs, values):
16051605
self.values = values
16061606

16071607
def putmask(
1608-
self, mask, new, inplace: bool = False, axis: int = 0, transpose: bool = False,
1608+
self, mask, new, inplace: bool = False, axis: int = 0, transpose: bool = False
16091609
) -> List["Block"]:
16101610
"""
16111611
See Block.putmask.__doc__
@@ -1816,7 +1816,7 @@ def diff(self, n: int, axis: int = 1) -> List["Block"]:
18161816
return super().diff(n, axis)
18171817

18181818
def shift(
1819-
self, periods: int, axis: int = 0, fill_value: Any = None,
1819+
self, periods: int, axis: int = 0, fill_value: Any = None
18201820
) -> List["ExtensionBlock"]:
18211821
"""
18221822
Shift the block by `periods`.
@@ -1833,7 +1833,7 @@ def shift(
18331833
]
18341834

18351835
def where(
1836-
self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0,
1836+
self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0
18371837
) -> List["Block"]:
18381838

18391839
cond = _extract_bool_array(cond)
@@ -1945,7 +1945,7 @@ def _can_hold_element(self, element: Any) -> bool:
19451945
)
19461946

19471947
def to_native_types(
1948-
self, na_rep="", float_format=None, decimal=".", quoting=None, **kwargs,
1948+
self, na_rep="", float_format=None, decimal=".", quoting=None, **kwargs
19491949
):
19501950
""" convert to our native types format """
19511951
values = self.values
@@ -2369,7 +2369,7 @@ def replace(self, to_replace, value, inplace=False, regex=False, convert=True):
23692369
if not np.can_cast(to_replace_values, bool):
23702370
return self
23712371
return super().replace(
2372-
to_replace, value, inplace=inplace, regex=regex, convert=convert,
2372+
to_replace, value, inplace=inplace, regex=regex, convert=convert
23732373
)
23742374

23752375

@@ -2453,18 +2453,18 @@ def replace(self, to_replace, value, inplace=False, regex=False, convert=True):
24532453

24542454
if not either_list and is_re(to_replace):
24552455
return self._replace_single(
2456-
to_replace, value, inplace=inplace, regex=True, convert=convert,
2456+
to_replace, value, inplace=inplace, regex=True, convert=convert
24572457
)
24582458
elif not (either_list or regex):
24592459
return super().replace(
2460-
to_replace, value, inplace=inplace, regex=regex, convert=convert,
2460+
to_replace, value, inplace=inplace, regex=regex, convert=convert
24612461
)
24622462
elif both_lists:
24632463
for to_rep, v in zip(to_replace, value):
24642464
result_blocks = []
24652465
for b in blocks:
24662466
result = b._replace_single(
2467-
to_rep, v, inplace=inplace, regex=regex, convert=convert,
2467+
to_rep, v, inplace=inplace, regex=regex, convert=convert
24682468
)
24692469
result_blocks = _extend_blocks(result, result_blocks)
24702470
blocks = result_blocks
@@ -2475,18 +2475,18 @@ def replace(self, to_replace, value, inplace=False, regex=False, convert=True):
24752475
result_blocks = []
24762476
for b in blocks:
24772477
result = b._replace_single(
2478-
to_rep, value, inplace=inplace, regex=regex, convert=convert,
2478+
to_rep, value, inplace=inplace, regex=regex, convert=convert
24792479
)
24802480
result_blocks = _extend_blocks(result, result_blocks)
24812481
blocks = result_blocks
24822482
return result_blocks
24832483

24842484
return self._replace_single(
2485-
to_replace, value, inplace=inplace, convert=convert, regex=regex,
2485+
to_replace, value, inplace=inplace, convert=convert, regex=regex
24862486
)
24872487

24882488
def _replace_single(
2489-
self, to_replace, value, inplace=False, regex=False, convert=True, mask=None,
2489+
self, to_replace, value, inplace=False, regex=False, convert=True, mask=None
24902490
):
24912491
"""
24922492
Replace elements by the given value.

0 commit comments

Comments
 (0)