Skip to content

Commit 6794a3c

Browse files
Merge remote-tracking branch 'upstream/master' into GH10285
2 parents 56f0ae0 + 56a9e75 commit 6794a3c

File tree

18 files changed

+212
-50
lines changed

18 files changed

+212
-50
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Update pre-commit config"
2+
3+
on:
4+
schedule:
5+
- cron: "0 7 * * 1" # At 07:00 on each Monday.
6+
workflow_dispatch:
7+
8+
jobs:
9+
update-pre-commit:
10+
if: github.repository_owner == 'pandas-dev'
11+
name: Autoupdate pre-commit config
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set up Python
15+
uses: actions/setup-python@v2
16+
- name: Cache multiple paths
17+
uses: actions/cache@v2
18+
with:
19+
path: |
20+
~/.cache/pre-commit
21+
~/.cache/pip
22+
key: pre-commit-autoupdate-${{ runner.os }}-build
23+
- name: Update pre-commit config packages
24+
uses: technote-space/create-pr-action@v2
25+
with:
26+
GITHUB_TOKEN: ${{ secrets.ACTION_TRIGGER_TOKEN }}
27+
EXECUTE_COMMANDS: |
28+
pip install pre-commit
29+
pre-commit autoupdate || (exit 0);
30+
pre-commit run -a || (exit 0);
31+
COMMIT_MESSAGE: "⬆️ UPGRADE: Autoupdate pre-commit config"
32+
PR_BRANCH_NAME: "pre-commit-config-update-${PR_ID}"
33+
PR_TITLE: "⬆️ UPGRADE: Autoupdate pre-commit config"

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ repos:
1818
types: [text]
1919
args: [--append-config=flake8/cython-template.cfg]
2020
- repo: https://github.com/PyCQA/isort
21-
rev: 5.6.3
21+
rev: 5.6.4
2222
hooks:
2323
- id: isort
2424
name: isort (python)
2525
- id: isort
2626
name: isort (cython)
2727
types: [cython]
2828
- repo: https://github.com/asottile/pyupgrade
29-
rev: v2.7.2
29+
rev: v2.7.3
3030
hooks:
3131
- id: pyupgrade
3232
args: [--py37-plus]
@@ -124,7 +124,7 @@ repos:
124124
hooks:
125125
- id: yesqa
126126
- repo: https://github.com/pre-commit/pre-commit-hooks
127-
rev: v3.2.0
127+
rev: v3.3.0
128128
hooks:
129129
- id: end-of-file-fixer
130130
exclude: ^LICENSES/|\.(html|csv|txt|svg|py)$

doc/source/user_guide/timeseries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ into ``freq`` keyword arguments. The available date offsets and associated frequ
879879
:header: "Date Offset", "Frequency String", "Description"
880880
:widths: 15, 15, 65
881881

882-
:class:`~pandas.tseries.offsets.DateOffset`, None, "Generic offset class, defaults to 1 calendar day"
882+
:class:`~pandas.tseries.offsets.DateOffset`, None, "Generic offset class, defaults to absolute 24 hours"
883883
:class:`~pandas.tseries.offsets.BDay` or :class:`~pandas.tseries.offsets.BusinessDay`, ``'B'``,"business day (weekday)"
884884
:class:`~pandas.tseries.offsets.CDay` or :class:`~pandas.tseries.offsets.CustomBusinessDay`, ``'C'``, "custom business day"
885885
:class:`~pandas.tseries.offsets.Week`, ``'W'``, "one week, optionally anchored on a day of the week"

doc/source/whatsnew/v1.2.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ Datetimelike
392392
- Bug in :meth:`DatetimeIndex.equals` and :meth:`TimedeltaIndex.equals` incorrectly considering ``int64`` indexes as equal (:issue:`36744`)
393393
- Bug in :meth:`TimedeltaIndex.sum` and :meth:`Series.sum` with ``timedelta64`` dtype on an empty index or series returning ``NaT`` instead of ``Timedelta(0)`` (:issue:`31751`)
394394
- Bug in :meth:`DatetimeArray.shift` incorrectly allowing ``fill_value`` with a mismatched timezone (:issue:`37299`)
395+
- Bug in adding a :class:`BusinessDay` with nonzero ``offset`` to a non-scalar other (:issue:`37457`)
395396

396397
Timedelta
397398
^^^^^^^^^
@@ -547,6 +548,7 @@ ExtensionArray
547548
- Fixed bug where ``astype()`` with equal dtype and ``copy=False`` would return a new object (:issue:`284881`)
548549
- Fixed bug when applying a NumPy ufunc with multiple outputs to a :class:`pandas.arrays.IntegerArray` returning None (:issue:`36913`)
549550
- Fixed an inconsistency in :class:`PeriodArray`'s ``__init__`` signature to those of :class:`DatetimeArray` and :class:`TimedeltaArray` (:issue:`37289`)
551+
- Reductions for :class:`BooleanArray`, :class:`Categorical`, :class:`DatetimeArray`, :class:`FloatingArray`, :class:`IntegerArray`, :class:`PeriodArray`, :class:`TimedeltaArray`, and :class:`PandasArray` are now keyword-only methods (:issue:`37541`)
550552

551553
Other
552554
^^^^^

pandas/_libs/tslibs/offsets.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,11 @@ cdef class BusinessDay(BusinessMixin):
13881388
@apply_array_wraps
13891389
def _apply_array(self, dtarr):
13901390
i8other = dtarr.view("i8")
1391-
return shift_bdays(i8other, self.n)
1391+
res = _shift_bdays(i8other, self.n)
1392+
if self.offset:
1393+
res = res.view("M8[ns]") + Timedelta(self.offset)
1394+
res = res.view("i8")
1395+
return res
13921396

13931397
def is_on_offset(self, dt: datetime) -> bool:
13941398
if self.normalize and not _is_normalized(dt):
@@ -3778,7 +3782,7 @@ cdef inline void _shift_quarters(const int64_t[:] dtindex,
37783782
out[i] = dtstruct_to_dt64(&dts)
37793783

37803784

3781-
cdef ndarray[int64_t] shift_bdays(const int64_t[:] i8other, int periods):
3785+
cdef ndarray[int64_t] _shift_bdays(const int64_t[:] i8other, int periods):
37823786
"""
37833787
Implementation of BusinessDay.apply_offset.
37843788

pandas/_typing.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@
3535
from pandas.core.arrays.base import ExtensionArray # noqa: F401
3636
from pandas.core.frame import DataFrame
3737
from pandas.core.generic import NDFrame # noqa: F401
38+
from pandas.core.groupby.generic import DataFrameGroupBy, SeriesGroupBy
3839
from pandas.core.indexes.base import Index
40+
from pandas.core.resample import Resampler
3941
from pandas.core.series import Series
42+
from pandas.core.window.rolling import BaseWindow
4043

4144
from pandas.io.formats.format import EngFormatter
4245

@@ -115,6 +118,14 @@
115118
List[AggFuncTypeBase],
116119
AggFuncTypeDict,
117120
]
121+
AggObjType = Union[
122+
"Series",
123+
"DataFrame",
124+
"SeriesGroupBy",
125+
"DataFrameGroupBy",
126+
"BaseWindow",
127+
"Resampler",
128+
]
118129

119130

120131
# for arbitrary kwargs passed during reading/writing files

pandas/core/aggregation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
AggFuncType,
2525
AggFuncTypeBase,
2626
AggFuncTypeDict,
27+
AggObjType,
2728
Axis,
2829
FrameOrSeries,
2930
FrameOrSeriesUnion,
@@ -530,7 +531,7 @@ def transform_str_or_callable(
530531

531532

532533
def aggregate(
533-
obj,
534+
obj: AggObjType,
534535
arg: AggFuncType,
535536
*args,
536537
**kwargs,
@@ -580,7 +581,7 @@ def aggregate(
580581

581582

582583
def agg_list_like(
583-
obj,
584+
obj: AggObjType,
584585
arg: List[AggFuncTypeBase],
585586
_axis: int,
586587
) -> FrameOrSeriesUnion:
@@ -672,7 +673,7 @@ def agg_list_like(
672673

673674

674675
def agg_dict_like(
675-
obj,
676+
obj: AggObjType,
676677
arg: AggFuncTypeDict,
677678
_axis: int,
678679
) -> FrameOrSeriesUnion:

pandas/core/arrays/boolean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def _values_for_argsort(self) -> np.ndarray:
424424
data[self._mask] = -1
425425
return data
426426

427-
def any(self, skipna: bool = True, **kwargs):
427+
def any(self, *, skipna: bool = True, **kwargs):
428428
"""
429429
Return whether any element is True.
430430
@@ -492,7 +492,7 @@ def any(self, skipna: bool = True, **kwargs):
492492
else:
493493
return self.dtype.na_value
494494

495-
def all(self, skipna: bool = True, **kwargs):
495+
def all(self, *, skipna: bool = True, **kwargs):
496496
"""
497497
Return whether all elements are True.
498498

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ def _reverse_indexer(self) -> Dict[Hashable, np.ndarray]:
19451945
# Reductions
19461946

19471947
@deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna")
1948-
def min(self, skipna=True, **kwargs):
1948+
def min(self, *, skipna=True, **kwargs):
19491949
"""
19501950
The minimum value of the object.
19511951
@@ -1981,7 +1981,7 @@ def min(self, skipna=True, **kwargs):
19811981
return self.categories[pointer]
19821982

19831983
@deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna")
1984-
def max(self, skipna=True, **kwargs):
1984+
def max(self, *, skipna=True, **kwargs):
19851985
"""
19861986
The maximum value of the object.
19871987

pandas/core/arrays/datetimelike.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ def __isub__(self, other):
12451245
# --------------------------------------------------------------
12461246
# Reductions
12471247

1248-
def min(self, axis=None, skipna=True, *args, **kwargs):
1248+
def min(self, *, axis=None, skipna=True, **kwargs):
12491249
"""
12501250
Return the minimum value of the Array or minimum along
12511251
an axis.
@@ -1256,7 +1256,7 @@ def min(self, axis=None, skipna=True, *args, **kwargs):
12561256
Index.min : Return the minimum value in an Index.
12571257
Series.min : Return the minimum value in a Series.
12581258
"""
1259-
nv.validate_min(args, kwargs)
1259+
nv.validate_min((), kwargs)
12601260
nv.validate_minmax_axis(axis, self.ndim)
12611261

12621262
if is_period_dtype(self.dtype):
@@ -1276,7 +1276,7 @@ def min(self, axis=None, skipna=True, *args, **kwargs):
12761276
return self._box_func(result)
12771277
return self._from_backing_data(result)
12781278

1279-
def max(self, axis=None, skipna=True, *args, **kwargs):
1279+
def max(self, *, axis=None, skipna=True, **kwargs):
12801280
"""
12811281
Return the maximum value of the Array or maximum along
12821282
an axis.
@@ -1289,7 +1289,7 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
12891289
"""
12901290
# TODO: skipna is broken with max.
12911291
# See https://github.com/pandas-dev/pandas/issues/24265
1292-
nv.validate_max(args, kwargs)
1292+
nv.validate_max((), kwargs)
12931293
nv.validate_minmax_axis(axis, self.ndim)
12941294

12951295
if is_period_dtype(self.dtype):
@@ -1309,7 +1309,7 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
13091309
return self._box_func(result)
13101310
return self._from_backing_data(result)
13111311

1312-
def mean(self, skipna=True, axis: Optional[int] = 0):
1312+
def mean(self, *, skipna=True, axis: Optional[int] = 0):
13131313
"""
13141314
Return the mean value of the Array.
13151315
@@ -1350,8 +1350,8 @@ def mean(self, skipna=True, axis: Optional[int] = 0):
13501350
return self._box_func(result)
13511351
return self._from_backing_data(result)
13521352

1353-
def median(self, axis: Optional[int] = None, skipna: bool = True, *args, **kwargs):
1354-
nv.validate_median(args, kwargs)
1353+
def median(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
1354+
nv.validate_median((), kwargs)
13551355

13561356
if axis is not None and abs(axis) >= self.ndim:
13571357
raise ValueError("abs(axis) must be less than ndim")

pandas/core/arrays/floating.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,19 +439,19 @@ def _cmp_method(self, other, op):
439439

440440
return BooleanArray(result, mask)
441441

442-
def sum(self, skipna=True, min_count=0, **kwargs):
442+
def sum(self, *, skipna=True, min_count=0, **kwargs):
443443
nv.validate_sum((), kwargs)
444444
return super()._reduce("sum", skipna=skipna, min_count=min_count)
445445

446-
def prod(self, skipna=True, min_count=0, **kwargs):
446+
def prod(self, *, skipna=True, min_count=0, **kwargs):
447447
nv.validate_prod((), kwargs)
448448
return super()._reduce("prod", skipna=skipna, min_count=min_count)
449449

450-
def min(self, skipna=True, **kwargs):
450+
def min(self, *, skipna=True, **kwargs):
451451
nv.validate_min((), kwargs)
452452
return super()._reduce("min", skipna=skipna)
453453

454-
def max(self, skipna=True, **kwargs):
454+
def max(self, *, skipna=True, **kwargs):
455455
nv.validate_max((), kwargs)
456456
return super()._reduce("max", skipna=skipna)
457457

pandas/core/arrays/integer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,19 @@ def _arith_method(self, other, op):
603603

604604
return self._maybe_mask_result(result, mask, other, op_name)
605605

606-
def sum(self, skipna=True, min_count=0, **kwargs):
606+
def sum(self, *, skipna=True, min_count=0, **kwargs):
607607
nv.validate_sum((), kwargs)
608608
return super()._reduce("sum", skipna=skipna, min_count=min_count)
609609

610-
def prod(self, skipna=True, min_count=0, **kwargs):
610+
def prod(self, *, skipna=True, min_count=0, **kwargs):
611611
nv.validate_prod((), kwargs)
612612
return super()._reduce("prod", skipna=skipna, min_count=min_count)
613613

614-
def min(self, skipna=True, **kwargs):
614+
def min(self, *, skipna=True, **kwargs):
615615
nv.validate_min((), kwargs)
616616
return super()._reduce("min", skipna=skipna)
617617

618-
def max(self, skipna=True, **kwargs):
618+
def max(self, *, skipna=True, **kwargs):
619619
nv.validate_max((), kwargs)
620620
return super()._reduce("max", skipna=skipna)
621621

0 commit comments

Comments
 (0)