Skip to content

Commit 6bc5677

Browse files
committed
Merge remote-tracking branch 'upstream/master' into testing-cln
2 parents 88e165d + 3b12293 commit 6bc5677

File tree

29 files changed

+497
-296
lines changed

29 files changed

+497
-296
lines changed

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,38 @@ repos:
3030
hooks:
3131
- id: pyupgrade
3232
args: [--py37-plus]
33+
- repo: https://github.com/pre-commit/pygrep-hooks
34+
rev: v1.6.0
35+
hooks:
36+
- id: rst-backticks
37+
# these exclusions should be removed and the files fixed
38+
exclude: (?x)(
39+
text\.rst|
40+
timeseries\.rst|
41+
visualization\.rst|
42+
missing_data\.rst|
43+
options\.rst|
44+
reshaping\.rst|
45+
scale\.rst|
46+
merging\.rst|
47+
cookbook\.rst|
48+
enhancingperf\.rst|
49+
groupby\.rst|
50+
io\.rst|
51+
overview\.rst|
52+
panel\.rst|
53+
plotting\.rst|
54+
10min\.rst|
55+
basics\.rst|
56+
categorical\.rst|
57+
contributing\.rst|
58+
contributing_docstring\.rst|
59+
extending\.rst|
60+
ecosystem\.rst|
61+
comparison_with_sql\.rst|
62+
install\.rst|
63+
calculate_statistics\.rst|
64+
combine_dataframes\.rst|
65+
v0\.|
66+
v1\.0\.|
67+
v1\.1\.[012])

.travis.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
language: python
22
python: 3.7
33

4+
addons:
5+
apt:
6+
update: true
7+
packages:
8+
- xvfb
9+
10+
services:
11+
- xvfb
12+
413
# To turn off cached cython files and compiler cache
514
# set NOCACHE-true
615
# To delete caches go to https://travis-ci.org/OWNER/REPOSITORY/caches or run
@@ -10,30 +19,27 @@ cache:
1019
ccache: true
1120
directories:
1221
- $HOME/.cache # cython cache
13-
- $HOME/.ccache # compiler cache
1422

1523
env:
1624
global:
17-
# Variable for test workers
1825
- PYTEST_WORKERS="auto"
1926
# create a github personal access token
2027
# cd pandas-dev/pandas
2128
# travis encrypt 'PANDAS_GH_TOKEN=personal_access_token' -r pandas-dev/pandas
2229
- secure: "EkWLZhbrp/mXJOx38CHjs7BnjXafsqHtwxPQrqWy457VDFWhIY1DMnIR/lOWG+a20Qv52sCsFtiZEmMfUjf0pLGXOqurdxbYBGJ7/ikFLk9yV2rDwiArUlVM9bWFnFxHvdz9zewBH55WurrY4ShZWyV+x2dWjjceWG5VpWeI6sA="
2330

2431
git:
25-
# for cloning
2632
depth: false
2733

2834
matrix:
2935
fast_finish: true
3036

3137
include:
32-
# In allowed failures
3338
- dist: bionic
3439
python: 3.9-dev
3540
env:
3641
- JOB="3.9-dev" PATTERN="(not slow and not network and not clipboard)"
42+
3743
- env:
3844
- JOB="3.8" ENV_FILE="ci/deps/travis-38.yaml" PATTERN="(not slow and not network and not clipboard)"
3945

@@ -42,7 +48,7 @@ matrix:
4248

4349
- arch: arm64
4450
env:
45-
- JOB="3.7, arm64" PYTEST_WORKERS=8 ENV_FILE="ci/deps/travis-37-arm64.yaml" PATTERN="(not slow and not network and not clipboard and not arm_slow)"
51+
- JOB="3.7, arm64" PYTEST_WORKERS=1 ENV_FILE="ci/deps/travis-37-arm64.yaml" PATTERN="(not slow and not network and not clipboard and not arm_slow)"
4652

4753
- env:
4854
- JOB="3.7, locale" ENV_FILE="ci/deps/travis-37-locale.yaml" PATTERN="((not slow and not network and not clipboard) or (single and db))" LOCALE_OVERRIDE="zh_CN.UTF-8" SQL="1"
@@ -71,12 +77,6 @@ before_install:
7177
- uname -a
7278
- git --version
7379
- ./ci/check_git_tags.sh
74-
# Because travis runs on Google Cloud and has a /etc/boto.cfg,
75-
# it breaks moto import, see:
76-
# https://github.com/spulec/moto/issues/1771
77-
# https://github.com/boto/boto/issues/3741
78-
# This overrides travis and tells it to look nowhere.
79-
- export BOTO_CONFIG=/dev/null
8080

8181
install:
8282
- echo "install start"

ci/build39.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash -e
22
# Special build for python3.9 until numpy puts its own wheels up
33

4-
sudo apt-get install build-essential gcc xvfb
54
pip install --no-deps -U pip wheel setuptools
65
pip install cython numpy python-dateutil pytz pytest pytest-xdist hypothesis
76

ci/setup_env.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ else
4242
fi
4343

4444
if [ "${TRAVIS_CPU_ARCH}" == "arm64" ]; then
45-
sudo apt-get update
46-
sudo apt-get -y install xvfb
47-
CONDA_URL="https://github.com/conda-forge/miniforge/releases/download/4.8.5-0/Miniforge3-4.8.5-0-Linux-aarch64.sh"
45+
CONDA_URL="https://github.com/conda-forge/miniforge/releases/download/4.8.5-1/Miniforge3-4.8.5-1-Linux-aarch64.sh"
4846
else
4947
CONDA_URL="https://repo.continuum.io/miniconda/Miniconda3-latest-$CONDA_OS.sh"
5048
fi
@@ -100,8 +98,6 @@ echo "conda list (root environment)"
10098
conda list
10199

102100
# Clean up any left-over from a previous build
103-
# (note workaround for https://github.com/conda/conda/issues/2679:
104-
# `conda env remove` issue)
105101
conda remove --all -q -y -n pandas-dev
106102

107103
echo
@@ -142,12 +138,6 @@ conda list pandas
142138
echo "[Build extensions]"
143139
python setup.py build_ext -q -i -j2
144140

145-
# TODO: Some of our environments end up with old versions of pip (10.x)
146-
# Adding a new enough version of pip to the requirements explodes the
147-
# solve time. Just using pip to update itself.
148-
# - py35_macos
149-
# - py35_compat
150-
# - py36_32bit
151141
echo "[Updating pip]"
152142
python -m pip install --no-deps -U pip wheel setuptools
153143

doc/source/user_guide/timeseries.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,12 @@ This type of slicing will work on a ``DataFrame`` with a ``DatetimeIndex`` as we
579579
partial string selection is a form of label slicing, the endpoints **will be** included. This
580580
would include matching times on an included date:
581581

582+
.. warning::
583+
584+
Indexing ``DataFrame`` rows with strings is deprecated in pandas 1.2.0 and will be removed in a future version. Use ``frame.loc[dtstring]`` instead.
585+
582586
.. ipython:: python
587+
:okwarning:
583588
584589
dft = pd.DataFrame(np.random.randn(100000, 1), columns=['A'],
585590
index=pd.date_range('20130101', periods=100000, freq='T'))
@@ -590,24 +595,28 @@ This starts on the very first time in the month, and includes the last date and
590595
time for the month:
591596

592597
.. ipython:: python
598+
:okwarning:
593599
594600
dft['2013-1':'2013-2']
595601
596602
This specifies a stop time **that includes all of the times on the last day**:
597603

598604
.. ipython:: python
605+
:okwarning:
599606
600607
dft['2013-1':'2013-2-28']
601608
602609
This specifies an **exact** stop time (and is not the same as the above):
603610

604611
.. ipython:: python
612+
:okwarning:
605613
606614
dft['2013-1':'2013-2-28 00:00:00']
607615
608616
We are stopping on the included end-point as it is part of the index:
609617

610618
.. ipython:: python
619+
:okwarning:
611620
612621
dft['2013-1-15':'2013-1-15 12:30:00']
613622
@@ -631,6 +640,7 @@ We are stopping on the included end-point as it is part of the index:
631640
Slicing with string indexing also honors UTC offset.
632641

633642
.. ipython:: python
643+
:okwarning:
634644
635645
df = pd.DataFrame([0], index=pd.DatetimeIndex(['2019-01-01'], tz='US/Pacific'))
636646
df
@@ -681,6 +691,7 @@ If index resolution is second, then the minute-accurate timestamp gives a
681691
If the timestamp string is treated as a slice, it can be used to index ``DataFrame`` with ``[]`` as well.
682692

683693
.. ipython:: python
694+
:okwarning:
684695
685696
dft_minute = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]},
686697
index=series_minute.index)
@@ -2027,6 +2038,7 @@ You can pass in dates and strings to ``Series`` and ``DataFrame`` with ``PeriodI
20272038
Passing a string representing a lower frequency than ``PeriodIndex`` returns partial sliced data.
20282039

20292040
.. ipython:: python
2041+
:okwarning:
20302042
20312043
ps['2011']
20322044

doc/source/whatsnew/v0.11.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ Enhancements
367367
- You can now select with a string from a DataFrame with a datelike index, in a similar way to a Series (:issue:`3070`)
368368

369369
.. ipython:: python
370+
:okwarning:
370371
371372
idx = pd.date_range("2001-10-1", periods=5, freq='M')
372373
ts = pd.Series(np.random.rand(len(idx)), index=idx)

doc/source/whatsnew/v1.1.3.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Fixed regressions
3535
- Fixed regression in :meth:`Series.__getitem__` incorrectly raising when the input was a frozenset (:issue:`35747`)
3636
- Fixed regression in :meth:`read_excel` with ``engine="odf"`` caused ``UnboundLocalError`` in some cases where cells had nested child nodes (:issue:`36122`, :issue:`35802`)
3737
- Fixed regression in :class:`DataFrame` and :class:`Series` comparisons between numeric arrays and strings (:issue:`35700`, :issue:`36377`)
38+
- Fixed regression in :meth:`DataFrame.apply` with ``raw=True`` and user-function returning string (:issue:`35940`)
3839
- Fixed regression when setting empty :class:`DataFrame` column to a :class:`Series` in preserving name of index in frame (:issue:`36527`)
3940
- Fixed regression in :class:`Period` incorrect value for ordinal over the maximum timestamp (:issue:`36430`)
4041

@@ -51,6 +52,7 @@ Bug fixes
5152
- Bug in :meth:`DataFrame.stack` raising a ``ValueError`` when stacking :class:`MultiIndex` columns based on position when the levels had duplicate names (:issue:`36353`)
5253
- Bug in :meth:`Series.astype` showing too much precision when casting from ``np.float32`` to string dtype (:issue:`36451`)
5354
- Bug in :meth:`Series.isin` and :meth:`DataFrame.isin` when using ``NaN`` and a row length above 1,000,000 (:issue:`22205`)
55+
- Bug in :func:`cut` raising a ``ValueError`` when passed a :class:`Series` of labels with ``ordered=False`` (:issue:`36603`)
5456

5557
.. ---------------------------------------------------------------------------
5658

doc/source/whatsnew/v1.2.0.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Other enhancements
117117
- :meth:`DataFrame.applymap` now supports ``na_action`` (:issue:`23803`)
118118
- :class:`Index` with object dtype supports division and multiplication (:issue:`34160`)
119119
- :meth:`DataFrame.explode` and :meth:`Series.explode` now support exploding of sets (:issue:`35614`)
120-
- `Styler` now allows direct CSS class name addition to individual data cells (:issue:`36159`)
120+
- ``Styler`` now allows direct CSS class name addition to individual data cells (:issue:`36159`)
121121
- :meth:`Rolling.mean()` and :meth:`Rolling.sum()` use Kahan summation to calculate the mean to avoid numerical problems (:issue:`10319`, :issue:`11645`, :issue:`13254`, :issue:`32761`, :issue:`36031`)
122122
- :meth:`DatetimeIndex.searchsorted`, :meth:`TimedeltaIndex.searchsorted`, :meth:`PeriodIndex.searchsorted`, and :meth:`Series.searchsorted` with datetimelike dtypes will now try to cast string arguments (listlike and scalar) to the matching datetimelike type (:issue:`36346`)
123123

@@ -213,6 +213,7 @@ Deprecations
213213
- Date parser functions :func:`~pandas.io.date_converters.parse_date_time`, :func:`~pandas.io.date_converters.parse_date_fields`, :func:`~pandas.io.date_converters.parse_all_fields` and :func:`~pandas.io.date_converters.generic_parser` from ``pandas.io.date_converters`` are deprecated and will be removed in a future version; use :func:`to_datetime` instead (:issue:`35741`)
214214
- :meth:`DataFrame.lookup` is deprecated and will be removed in a future version, use :meth:`DataFrame.melt` and :meth:`DataFrame.loc` instead (:issue:`18682`)
215215
- The :meth:`Index.to_native_types` is deprecated. Use ``.astype(str)`` instead (:issue:`28867`)
216+
- Deprecated indexing :class:`DataFrame` rows with datetime-like strings ``df[string]``, use ``df.loc[string]`` instead (:issue:`36179`)
216217

217218
.. ---------------------------------------------------------------------------
218219
@@ -222,12 +223,12 @@ Deprecations
222223
Performance improvements
223224
~~~~~~~~~~~~~~~~~~~~~~~~
224225

225-
- Performance improvements when creating DataFrame or Series with dtype `str` or :class:`StringDtype` from array with many string elements (:issue:`36304`, :issue:`36317`, :issue:`36325`, :issue:`36432`)
226+
- Performance improvements when creating DataFrame or Series with dtype ``str`` or :class:`StringDtype` from array with many string elements (:issue:`36304`, :issue:`36317`, :issue:`36325`, :issue:`36432`)
226227
- Performance improvement in :meth:`GroupBy.agg` with the ``numba`` engine (:issue:`35759`)
227228
- Performance improvements when creating :meth:`pd.Series.map` from a huge dictionary (:issue:`34717`)
228229
- Performance improvement in :meth:`GroupBy.transform` with the ``numba`` engine (:issue:`36240`)
229230
- ``Styler`` uuid method altered to compress data transmission over web whilst maintaining reasonably low table collision probability (:issue:`36345`)
230-
- Performance improvement in :meth:`pd.to_datetime` with non-`ns` time unit for `float` `dtype` columns (:issue:`20445`)
231+
- Performance improvement in :meth:`pd.to_datetime` with non-ns time unit for ``float`` ``dtype`` columns (:issue:`20445`)
231232

232233
.. ---------------------------------------------------------------------------
233234
@@ -262,7 +263,7 @@ Timedelta
262263
Timezones
263264
^^^^^^^^^
264265

265-
- Bug in :func:`date_range` was raising AmbiguousTimeError for valid input with `ambiguous=False` (:issue:`35297`)
266+
- Bug in :func:`date_range` was raising AmbiguousTimeError for valid input with ``ambiguous=False`` (:issue:`35297`)
266267
-
267268

268269

@@ -271,6 +272,7 @@ Numeric
271272
- Bug in :func:`to_numeric` where float precision was incorrect (:issue:`31364`)
272273
- Bug in :meth:`DataFrame.any` with ``axis=1`` and ``bool_only=True`` ignoring the ``bool_only`` keyword (:issue:`32432`)
273274
- Bug in :meth:`Series.equals` where a ``ValueError`` was raised when numpy arrays were compared to scalars (:issue:`35267`)
275+
- Bug in :class:`Series` where two :class:`Series` each have a :class:`DatetimeIndex` with different timezones having those indexes incorrectly changed when performing arithmetic operations (:issue:`33671`)
274276
-
275277

276278
Conversion
@@ -303,29 +305,29 @@ Indexing
303305
Missing
304306
^^^^^^^
305307

306-
- Bug in :meth:`SeriesGroupBy.transform` now correctly handles missing values for `dropna=False` (:issue:`35014`)
308+
- Bug in :meth:`SeriesGroupBy.transform` now correctly handles missing values for ``dropna=False`` (:issue:`35014`)
307309
-
308310

309311
MultiIndex
310312
^^^^^^^^^^
311313

312-
- Bug in :meth:`DataFrame.xs` when used with :class:`IndexSlice` raises ``TypeError`` with message `Expected label or tuple of labels` (:issue:`35301`)
314+
- Bug in :meth:`DataFrame.xs` when used with :class:`IndexSlice` raises ``TypeError`` with message ``"Expected label or tuple of labels"`` (:issue:`35301`)
313315
-
314316

315317
I/O
316318
^^^
317319

318320
- :func:`read_sas` no longer leaks resources on failure (:issue:`35566`)
319321
- Bug in :meth:`to_csv` caused a ``ValueError`` when it was called with a filename in combination with ``mode`` containing a ``b`` (:issue:`35058`)
320-
- In :meth:`read_csv` `float_precision='round_trip'` now handles `decimal` and `thousands` parameters (:issue:`35365`)
322+
- In :meth:`read_csv` ``float_precision='round_trip'`` now handles ``decimal`` and ``thousands`` parameters (:issue:`35365`)
321323
- :meth:`to_pickle` and :meth:`read_pickle` were closing user-provided file objects (:issue:`35679`)
322-
- :meth:`to_csv` passes compression arguments for `'gzip'` always to `gzip.GzipFile` (:issue:`28103`)
324+
- :meth:`to_csv` passes compression arguments for ``'gzip'`` always to ``gzip.GzipFile`` (:issue:`28103`)
323325
- :meth:`to_csv` did not support zip compression for binary file object not having a filename (:issue:`35058`)
324-
- :meth:`to_csv` and :meth:`read_csv` did not honor `compression` and `encoding` for path-like objects that are internally converted to file-like objects (:issue:`35677`, :issue:`26124`, and :issue:`32392`)
326+
- :meth:`to_csv` and :meth:`read_csv` did not honor ``compression`` and ``encoding`` for path-like objects that are internally converted to file-like objects (:issue:`35677`, :issue:`26124`, and :issue:`32392`)
325327
- :meth:`to_picke` and :meth:`read_pickle` did not support compression for file-objects (:issue:`26237`, :issue:`29054`, and :issue:`29570`)
326328
- Bug in :func:`LongTableBuilder.middle_separator` was duplicating LaTeX longtable entires in the List of Tables of a LaTeX document (:issue:`34360`)
327-
- Bug in :meth:`read_csv` with `engine='python'` truncating data if multiple items present in first row and first element started with BOM (:issue:`36343`)
328-
- Removed ``private_key`` and ``verbose`` from :func:`read_gbq` as they are no longer supported in `pandas-gbq` (:issue:`34654` :issue:`30200`)
329+
- Bug in :meth:`read_csv` with ``engine='python'`` truncating data if multiple items present in first row and first element started with BOM (:issue:`36343`)
330+
- Removed ``private_key`` and ``verbose`` from :func:`read_gbq` as they are no longer supported in ``pandas-gbq`` (:issue:`34654`, :issue:`30200`)
329331

330332
Plotting
331333
^^^^^^^^

doc/sphinxext/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pandas documentation. These copies originate from other projects:
77
- ``numpydoc`` - Numpy's Sphinx extensions: this can be found at its own
88
repository: https://github.com/numpy/numpydoc
99
- ``ipython_directive`` and ``ipython_console_highlighting`` in the folder
10-
`ipython_sphinxext` - Sphinx extensions from IPython: these are included
10+
``ipython_sphinxext`` - Sphinx extensions from IPython: these are included
1111
in IPython: https://github.com/ipython/ipython/tree/master/IPython/sphinxext
1212

1313
.. note::

pandas/core/aggregation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from collections import defaultdict
77
from functools import partial
88
from typing import (
9+
TYPE_CHECKING,
910
Any,
1011
Callable,
1112
DefaultDict,
@@ -26,7 +27,9 @@
2627
from pandas.core.base import SpecificationError
2728
import pandas.core.common as com
2829
from pandas.core.indexes.api import Index
29-
from pandas.core.series import Series
30+
31+
if TYPE_CHECKING:
32+
from pandas.core.series import Series
3033

3134

3235
def reconstruct_func(
@@ -281,7 +284,7 @@ def relabel_result(
281284
func: Dict[str, List[Union[Callable, str]]],
282285
columns: Iterable[Label],
283286
order: Iterable[int],
284-
) -> Dict[Label, Series]:
287+
) -> Dict[Label, "Series"]:
285288
"""
286289
Internal function to reorder result if relabelling is True for
287290
dataframe.agg, and return the reordered result in dict.
@@ -308,10 +311,10 @@ def relabel_result(
308311
reordered_indexes = [
309312
pair[0] for pair in sorted(zip(columns, order), key=lambda t: t[1])
310313
]
311-
reordered_result_in_dict: Dict[Label, Series] = {}
314+
reordered_result_in_dict: Dict[Label, "Series"] = {}
312315
idx = 0
313316

314-
reorder_mask = not isinstance(result, Series) and len(result.columns) > 1
317+
reorder_mask = not isinstance(result, ABCSeries) and len(result.columns) > 1
315318
for col, fun in func.items():
316319
s = result[col].dropna()
317320

0 commit comments

Comments
 (0)