Skip to content

Commit cd98e95

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 37517-percentage-sign-columnname
2 parents 766b2d9 + 56a9e75 commit cd98e95

File tree

92 files changed

+1393
-962
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1393
-962
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: 13 additions & 5 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]
@@ -66,9 +66,17 @@ repos:
6666
from\ pandas\.core\ import\ common|
6767
6868
# Check for imports from collections.abc instead of `from collections import abc`
69-
from\ collections\.abc\ import|
69+
from\ collections\.abc\ import
7070
71-
from\ numpy\ import\ nan
71+
- id: non-standard-numpy.random-related-imports
72+
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
73+
language: pygrep
74+
exclude: pandas/_testing.py
75+
entry: |
76+
(?x)
77+
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
78+
from\ numpy\ import\ random|
79+
from\ numpy.random\ import
7280
types: [python]
7381
- id: non-standard-imports-in-tests
7482
name: Check for non-standard imports in test suite
@@ -116,7 +124,7 @@ repos:
116124
hooks:
117125
- id: yesqa
118126
- repo: https://github.com/pre-commit/pre-commit-hooks
119-
rev: v3.2.0
127+
rev: v3.3.0
120128
hooks:
121129
- id: end-of-file-fixer
122130
exclude: ^LICENSES/|\.(html|csv|txt|svg|py)$

ci/azure/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
py38_np18:
1717
ENV_FILE: ci/deps/azure-windows-38.yaml
1818
CONDA_PY: "38"
19-
PATTERN: "not slow and not network"
19+
PATTERN: "not slow and not network and not high_memory"
2020

2121
steps:
2222
- powershell: |

ci/run_tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fi
2222

2323
PYTEST_CMD="${XVFB}pytest -m \"$PATTERN\" -n $PYTEST_WORKERS --dist=loadfile -s --strict --durations=30 --junitxml=test-data.xml $TEST_ARGS $COVERAGE pandas"
2424

25+
if [[ $(uname) != "Linux" && $(uname) != "Darwin" ]]; then
26+
# GH#37455 windows py38 build appears to be running out of memory
27+
# skip collection of window tests
28+
PYTEST_CMD="$PYTEST_CMD --ignore=pandas/tests/window/"
29+
fi
30+
2531
echo $PYTEST_CMD
2632
sh -c "$PYTEST_CMD"
2733

doc/source/development/contributing.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,14 @@ to run its checks by running::
837837

838838
without having to have done ``pre-commit install`` beforehand.
839839

840-
Note that if you have conflicting installations of ``virtualenv``, then you may get an
841-
error - see `here <https://github.com/pypa/virtualenv/issues/1875>`_.
840+
.. note::
841+
842+
If you have conflicting installations of ``virtualenv``, then you may get an
843+
error - see `here <https://github.com/pypa/virtualenv/issues/1875>`_.
844+
845+
Also, due to a `bug in virtualenv <https://github.com/pypa/virtualenv/issues/1986>`_,
846+
you may run into issues if you're using conda. To solve this, you can downgrade
847+
``virtualenv`` to version ``20.0.33``.
842848

843849
Backwards compatibility
844850
~~~~~~~~~~~~~~~~~~~~~~~

doc/source/user_guide/computation.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ The list of recognized types are the `scipy.signal window functions
451451
* ``slepian`` (needs width)
452452
* ``exponential`` (needs tau).
453453

454+
.. versionadded:: 1.2.0
455+
456+
All Scipy window types, concurrent with your installed version, are recognized ``win_types``.
457+
454458
.. ipython:: python
455459
456460
ser = pd.Series(np.random.randn(10), index=pd.date_range("1/1/2000", periods=10))

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/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Version 1.1
2424
.. toctree::
2525
:maxdepth: 2
2626

27+
v1.1.5
2728
v1.1.4
2829
v1.1.3
2930
v1.1.2

doc/source/whatsnew/v1.1.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Bug fixes
5252
Contributors
5353
~~~~~~~~~~~~
5454

55-
.. contributors:: v1.1.3..v1.1.4|HEAD
55+
.. contributors:: v1.1.3..v1.1.4

doc/source/whatsnew/v1.1.5.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _whatsnew_115:
2+
3+
What's new in 1.1.5 (??)
4+
------------------------
5+
6+
These are the changes in pandas 1.1.5. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
{{ header }}
10+
11+
.. ---------------------------------------------------------------------------
12+
13+
.. _whatsnew_115.regressions:
14+
15+
Fixed regressions
16+
~~~~~~~~~~~~~~~~~
17+
-
18+
-
19+
20+
.. ---------------------------------------------------------------------------
21+
22+
.. _whatsnew_115.bug_fixes:
23+
24+
Bug fixes
25+
~~~~~~~~~
26+
-
27+
-
28+
29+
.. ---------------------------------------------------------------------------
30+
31+
.. _whatsnew_115.contributors:
32+
33+
Contributors
34+
~~~~~~~~~~~~
35+
36+
.. contributors:: v1.1.4..v1.1.5|HEAD

doc/source/whatsnew/v1.2.0.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ Other enhancements
227227
- :meth:`DataFrame.to_parquet` now returns a ``bytes`` object when no ``path`` argument is passed (:issue:`37105`)
228228
- :class:`Rolling` now supports the ``closed`` argument for fixed windows (:issue:`34315`)
229229
- :class:`DatetimeIndex` and :class:`Series` with ``datetime64`` or ``datetime64tz`` dtypes now support ``std`` (:issue:`37436`)
230+
- :class:`Window` now supports all Scipy window types in ``win_type`` with flexible keyword argument support (:issue:`34556`)
230231

231232
.. _whatsnew_120.api_breaking.python:
232233

@@ -309,6 +310,13 @@ Optional libraries below the lowest tested version may still work, but are not c
309310

310311
See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more.
311312

313+
.. _whatsnew_200.api.other:
314+
315+
Other API changes
316+
^^^^^^^^^^^^^^^^^
317+
318+
- Sorting in descending order is now stable for :meth:`Series.sort_values` and :meth:`Index.sort_values` for DateTime-like :class:`Index` subclasses. This will affect sort order when sorting :class:`DataFrame` on multiple columns, sorting with a key function that produces duplicates, or requesting the sorting index when using :meth:`Index.sort_values`. When using :meth:`Series.value_counts`, count of missing values is no longer the last in the list of duplicate counts, and its position corresponds to the position in the original :class:`Series`. When using :meth:`Index.sort_values` for DateTime-like :class:`Index` subclasses, NaTs ignored the ``na_position`` argument and were sorted to the beggining. Now they respect ``na_position``, the default being ``last``, same as other :class:`Index` subclasses. (:issue:`35992`)
319+
312320
.. ---------------------------------------------------------------------------
313321
314322
.. _whatsnew_120.deprecations:
@@ -329,6 +337,7 @@ Deprecations
329337
- :meth:`Rolling.count` with ``min_periods=None`` will default to the size of the window in a future version (:issue:`31302`)
330338
- Deprecated slice-indexing on timezone-aware :class:`DatetimeIndex` with naive ``datetime`` objects, to match scalar indexing behavior (:issue:`36148`)
331339
- :meth:`Index.ravel` returning a ``np.ndarray`` is deprecated, in the future this will return a view on the same index (:issue:`19956`)
340+
- Deprecate use of strings denoting units with 'M', 'Y' or 'y' in :func:`~pandas.to_timedelta` (:issue:`36666`)
332341

333342
.. ---------------------------------------------------------------------------
334343
@@ -380,6 +389,8 @@ Datetimelike
380389
- :class:`Timestamp` and :class:`DatetimeIndex` comparisons between timezone-aware and timezone-naive objects now follow the standard library ``datetime`` behavior, returning ``True``/``False`` for ``!=``/``==`` and raising for inequality comparisons (:issue:`28507`)
381390
- Bug in :meth:`DatetimeIndex.equals` and :meth:`TimedeltaIndex.equals` incorrectly considering ``int64`` indexes as equal (:issue:`36744`)
382391
- 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`)
392+
- Bug in :meth:`DatetimeArray.shift` incorrectly allowing ``fill_value`` with a mismatched timezone (:issue:`37299`)
393+
- Bug in adding a :class:`BusinessDay` with nonzero ``offset`` to a non-scalar other (:issue:`37457`)
383394

384395
Timedelta
385396
^^^^^^^^^
@@ -425,7 +436,7 @@ Strings
425436

426437
Interval
427438
^^^^^^^^
428-
439+
- Bug in :meth:`IntervalIndex.take` with negative indices and ``fill_value=None`` (:issue:`37330`)
429440
-
430441
-
431442

@@ -477,6 +488,7 @@ I/O
477488
- Bug in :meth:`DataFrame.to_html`, :meth:`DataFrame.to_string`, and :meth:`DataFrame.to_latex` ignoring the ``na_rep`` argument when ``float_format`` was also specified (:issue:`9046`, :issue:`13828`)
478489
- Bug in output rendering of complex numbers showing too many trailing zeros (:issue:`36799`)
479490
- Bug in :class:`HDFStore` threw a ``TypeError`` when exporting an empty :class:`DataFrame` with ``datetime64[ns, tz]`` dtypes with a fixed HDF5 store (:issue:`20594`)
491+
- Bug in :class:`HDFStore` was dropping timezone information when exporting :class:`Series` with ``datetime64[ns, tz]`` dtypes with a fixed HDF5 store (:issue:`20594`)
480492

481493
Plotting
482494
^^^^^^^^
@@ -506,6 +518,7 @@ Groupby/resample/rolling
506518
- Bug in :meth:`DataFrameGroupBy.rolling` returned wrong values with timeaware window containing ``NaN``. Raises ``ValueError`` because windows are not monotonic now (:issue:`34617`)
507519
- Bug in :meth:`Rolling.__iter__` where a ``ValueError`` was not raised when ``min_periods`` was larger than ``window`` (:issue:`37156`)
508520
- Using :meth:`Rolling.var()` instead of :meth:`Rolling.std()` avoids numerical issues for :meth:`Rolling.corr()` when :meth:`Rolling.var()` is still within floating point precision while :meth:`Rolling.std()` is not (:issue:`31286`)
521+
- Bug in :meth:`df.groupby(..).quantile() <pandas.core.groupby.DataFrameGroupBy.quantile>` and :meth:`df.resample(..).quantile() <pandas.core.resample.Resampler.quantile>` raised ``TypeError`` when values were of type ``Timedelta`` (:issue:`29485`)
509522
- Bug in :meth:`Rolling.median` and :meth:`Rolling.quantile` returned wrong values for :class:`BaseIndexer` subclasses with non-monotonic starting or ending points for windows (:issue:`37153`)
510523

511524
Reshaping
@@ -516,6 +529,7 @@ Reshaping
516529
- Bug in func :meth:`crosstab` when using multiple columns with ``margins=True`` and ``normalize=True`` (:issue:`35144`)
517530
- Bug in :meth:`DataFrame.agg` with ``func={'name':<FUNC>}`` incorrectly raising ``TypeError`` when ``DataFrame.columns==['Name']`` (:issue:`36212`)
518531
- Bug in :meth:`Series.transform` would give incorrect results or raise when the argument ``func`` was dictionary (:issue:`35811`)
532+
- Bug in :meth:`DataFrame.pivot` did not preserve :class:`MultiIndex` level names for columns when rows and columns both multiindexed (:issue:`36360`)
519533
- Bug in :func:`join` returned a non deterministic level-order for the resulting :class:`MultiIndex` (:issue:`36910`)
520534
-
521535

@@ -532,6 +546,7 @@ ExtensionArray
532546
- Fixed bug where ``astype()`` with equal dtype and ``copy=False`` would return a new object (:issue:`284881`)
533547
- Fixed bug when applying a NumPy ufunc with multiple outputs to a :class:`pandas.arrays.IntegerArray` returning None (:issue:`36913`)
534548
- Fixed an inconsistency in :class:`PeriodArray`'s ``__init__`` signature to those of :class:`DatetimeArray` and :class:`TimedeltaArray` (:issue:`37289`)
549+
- 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`)
535550

536551
Other
537552
^^^^^

pandas/_libs/internals.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ cdef slice slice_canonize(slice s):
207207
Convert slice to canonical bounded form.
208208
"""
209209
cdef:
210-
Py_ssize_t start = 0, stop = 0, step = 1, length
210+
Py_ssize_t start = 0, stop = 0, step = 1
211211

212212
if s.step is None:
213213
step = 1
@@ -239,7 +239,7 @@ cdef slice slice_canonize(slice s):
239239
if stop > start:
240240
stop = start
241241

242-
if start < 0 or (stop < 0 and s.stop is not None):
242+
if start < 0 or (stop < 0 and s.stop is not None and step > 0):
243243
raise ValueError("unbounded slice")
244244

245245
if stop < 0:

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/_libs/tslibs/timedeltas.pyx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections
2+
import warnings
23

34
import cython
45

@@ -466,6 +467,15 @@ cdef inline timedelta_from_spec(object number, object frac, object unit):
466467

467468
try:
468469
unit = ''.join(unit)
470+
471+
if unit in ["M", "Y", "y"]:
472+
warnings.warn(
473+
"Units 'M', 'Y' and 'y' do not represent unambiguous "
474+
"timedelta values and will be removed in a future version",
475+
FutureWarning,
476+
stacklevel=2,
477+
)
478+
469479
if unit == 'M':
470480
# To parse ISO 8601 string, 'M' should be treated as minute,
471481
# not month
@@ -634,9 +644,11 @@ cdef inline int64_t parse_iso_format_string(str ts) except? -1:
634644
else:
635645
neg = 1
636646
elif c in ['W', 'D', 'H', 'M']:
637-
unit.append(c)
638647
if c in ['H', 'M'] and len(number) > 2:
639648
raise ValueError(err_msg)
649+
if c == 'M':
650+
c = 'min'
651+
unit.append(c)
640652
r = timedelta_from_spec(number, '0', unit)
641653
result += timedelta_as_neg(r, neg)
642654

pandas/_typing.py

Lines changed: 14 additions & 1 deletion
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

@@ -109,11 +112,21 @@
109112

110113
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
111114
AggFuncTypeBase = Union[Callable, str]
115+
AggFuncTypeDict = Dict[Label, Union[AggFuncTypeBase, List[AggFuncTypeBase]]]
112116
AggFuncType = Union[
113117
AggFuncTypeBase,
114118
List[AggFuncTypeBase],
115-
Dict[Label, Union[AggFuncTypeBase, List[AggFuncTypeBase]]],
119+
AggFuncTypeDict,
116120
]
121+
AggObjType = Union[
122+
"Series",
123+
"DataFrame",
124+
"SeriesGroupBy",
125+
"DataFrameGroupBy",
126+
"BaseWindow",
127+
"Resampler",
128+
]
129+
117130

118131
# for arbitrary kwargs passed during reading/writing files
119132
StorageOptions = Optional[Dict[str, Any]]

0 commit comments

Comments
 (0)