Skip to content

Commit 3e847e9

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bug/categorical-indexing-1row-df
* upstream/master: (109 commits) stronger typing in libreduction (pandas-dev#29502) API: rename labels to codes (pandas-dev#29509) CLN: remove unnecessary type checks (pandas-dev#29517) implement _BaseGrouper (pandas-dev#29520) CLN: F-string formatting in pandas/_libs/*.pyx (pandas-dev#29527) Fixed more SS03 errors (pandas-dev#29540) consolidate dim checks (pandas-dev#29536) REF: separate out _get_cython_func_and_vals (pandas-dev#29537) remove unnecessary exception (pandas-dev#29538) TST:Add test to check single category col returns series with single row slice (pandas-dev#29521) Make color validation more forgiving (pandas-dev#29122) DOC: update bottleneck repo and documentation urls (pandas-dev#29516) TST: add test for df construction from dict with tuples (pandas-dev#29497) add test for pd.melt dtypes preservation (pandas-dev#29510) updated DataFrame.equals docstring (pandas-dev#29496) Resolved merge conflicts (pandas-dev#29506) DOC: Improved pandas/compact/__init__.py (pandas-dev#29507) DOC: Update performance comparison section of io docs (pandas-dev#28890) TST: add test for df.where() with category dtype (pandas-dev#29454) DOC: Fix docs on merging categoricals. (pandas-dev#28185) ...
2 parents 2dfa594 + 07efdd4 commit 3e847e9

File tree

206 files changed

+4540
-4113
lines changed

Some content is hidden

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

206 files changed

+4540
-4113
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ matrix:
3232
include:
3333
- dist: bionic
3434
# 18.04
35-
python: 3.8-dev
35+
python: 3.8.0
3636
env:
3737
- JOB="3.8-dev" PATTERN="(not slow and not network)"
3838

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ or for installing in [development mode](https://pip.pypa.io/en/latest/reference/
190190

191191

192192
```sh
193-
python -m pip install --no-build-isolation -e .
193+
python -m pip install -e . --no-build-isolation --no-use-pep517
194194
```
195195

196196
If you have `make`, you can also use `make develop` to run the same command.

ci/azure/posix.yml

+16-14
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ jobs:
99
strategy:
1010
matrix:
1111
${{ if eq(parameters.name, 'macOS') }}:
12-
py35_macos:
13-
ENV_FILE: ci/deps/azure-macos-35.yaml
14-
CONDA_PY: "35"
12+
py36_macos:
13+
ENV_FILE: ci/deps/azure-macos-36.yaml
14+
CONDA_PY: "36"
1515
PATTERN: "not slow and not network"
1616

1717
${{ if eq(parameters.name, 'Linux') }}:
18-
py35_compat:
19-
ENV_FILE: ci/deps/azure-35-compat.yaml
20-
CONDA_PY: "35"
18+
py36_minimum_versions:
19+
ENV_FILE: ci/deps/azure-36-minimum_versions.yaml
20+
CONDA_PY: "36"
2121
PATTERN: "not slow and not network"
22-
2322
py36_locale_slow_old_np:
2423
ENV_FILE: ci/deps/azure-36-locale.yaml
2524
CONDA_PY: "36"
@@ -45,13 +44,16 @@ jobs:
4544
PATTERN: "not slow and not network"
4645
LOCALE_OVERRIDE: "zh_CN.UTF-8"
4746

48-
py37_np_dev:
49-
ENV_FILE: ci/deps/azure-37-numpydev.yaml
50-
CONDA_PY: "37"
51-
PATTERN: "not slow and not network"
52-
TEST_ARGS: "-W error"
53-
PANDAS_TESTING_MODE: "deprecate"
54-
EXTRA_APT: "xsel"
47+
# https://github.com/pandas-dev/pandas/issues/29432
48+
# py37_np_dev:
49+
# ENV_FILE: ci/deps/azure-37-numpydev.yaml
50+
# CONDA_PY: "37"
51+
# PATTERN: "not slow and not network"
52+
# TEST_ARGS: "-W error"
53+
# PANDAS_TESTING_MODE: "deprecate"
54+
# EXTRA_APT: "xsel"
55+
# # TODO:
56+
# continueOnError: true
5557

5658
steps:
5759
- script: |

ci/deps/azure-35-compat.yaml renamed to ci/deps/azure-36-minimum_versions.yaml

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,23 @@ channels:
55
dependencies:
66
- beautifulsoup4=4.6.0
77
- bottleneck=1.2.1
8+
- cython>=0.29.13
89
- jinja2=2.8
910
- numexpr=2.6.2
1011
- numpy=1.13.3
1112
- openpyxl=2.4.8
1213
- pytables=3.4.2
1314
- python-dateutil=2.6.1
14-
- python=3.5.3
15+
- python=3.6.1
1516
- pytz=2017.2
1617
- scipy=0.19.0
1718
- xlrd=1.1.0
1819
- xlsxwriter=0.9.8
1920
- xlwt=1.2.0
2021
# universal
22+
- html5lib=1.0.1
2123
- hypothesis>=3.58.0
24+
- pytest=4.5.0
2225
- pytest-xdist
2326
- pytest-mock
2427
- pytest-azurepipelines
25-
- pip
26-
- pip:
27-
# for python 3.5, pytest>=4.0.2, cython>=0.29.13 is not available in conda
28-
- cython>=0.29.13
29-
- pytest==4.5.0
30-
- html5lib==1.0b2

ci/deps/azure-macos-35.yaml renamed to ci/deps/azure-macos-36.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- openpyxl
1515
- pyarrow
1616
- pytables
17-
- python=3.5.*
17+
- python=3.6.*
1818
- python-dateutil==2.6.1
1919
- pytz
2020
- xarray

doc/source/development/contributing.rst

+4-27
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ We'll now kick off a three-step process:
208208
209209
# Build and install pandas
210210
python setup.py build_ext --inplace -j 4
211-
python -m pip install -e . --no-build-isolation
211+
python -m pip install -e . --no-build-isolation --no-use-pep517
212212
213213
At this point you should be able to import pandas from your locally built version::
214214

@@ -236,7 +236,7 @@ Creating a Python environment (pip)
236236
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237237

238238
If you aren't using conda for your development environment, follow these instructions.
239-
You'll need to have at least python3.5 installed on your system.
239+
You'll need to have at least Python 3.6.1 installed on your system.
240240

241241
**Unix**/**Mac OS**
242242

@@ -255,7 +255,7 @@ You'll need to have at least python3.5 installed on your system.
255255
256256
# Build and install pandas
257257
python setup.py build_ext --inplace -j 0
258-
python -m pip install -e . --no-build-isolation
258+
python -m pip install -e . --no-build-isolation --no-use-pep517
259259
260260
**Windows**
261261

@@ -847,29 +847,6 @@ The limitation here is that while a human can reasonably understand that ``is_nu
847847
848848
With custom types and inference this is not always possible so exceptions are made, but every effort should be exhausted to avoid ``cast`` before going down such paths.
849849

850-
Syntax Requirements
851-
~~~~~~~~~~~~~~~~~~~
852-
853-
Because *pandas* still supports Python 3.5, :pep:`526` does not apply and variables **must** be annotated with type comments. Specifically, this is a valid annotation within pandas:
854-
855-
.. code-block:: python
856-
857-
primes = [] # type: List[int]
858-
859-
Whereas this is **NOT** allowed:
860-
861-
.. code-block:: python
862-
863-
primes: List[int] = [] # not supported in Python 3.5!
864-
865-
Note that function signatures can always be annotated per :pep:`3107`:
866-
867-
.. code-block:: python
868-
869-
def sum_of_primes(primes: List[int] = []) -> int:
870-
...
871-
872-
873850
Pandas-specific Types
874851
~~~~~~~~~~~~~~~~~~~~~
875852

@@ -1296,7 +1273,7 @@ environment by::
12961273

12971274
or, to use a specific Python interpreter,::
12981275

1299-
asv run -e -E existing:python3.5
1276+
asv run -e -E existing:python3.6
13001277

13011278
This will display stderr from the benchmarks, and use your local
13021279
``python`` that comes from your ``$PATH``.

doc/source/development/policies.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Pandas may change the behavior of experimental features at any time.
5151
Python Support
5252
~~~~~~~~~~~~~~
5353

54-
Pandas will only drop support for specific Python versions (e.g. 3.5.x, 3.6.x) in
54+
Pandas will only drop support for specific Python versions (e.g. 3.6.x, 3.7.x) in
5555
pandas **major** releases.
5656

5757
.. _SemVer: https://semver.org

doc/source/getting_started/basics.rst

+34-11
Original file line numberDiff line numberDiff line change
@@ -753,28 +753,51 @@ on an entire ``DataFrame`` or ``Series``, row- or column-wise, or elementwise.
753753
Tablewise function application
754754
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
755755

756-
``DataFrames`` and ``Series`` can of course just be passed into functions.
756+
``DataFrames`` and ``Series`` can be passed into functions.
757757
However, if the function needs to be called in a chain, consider using the :meth:`~DataFrame.pipe` method.
758-
Compare the following
759758

760-
.. code-block:: python
759+
First some setup:
760+
761+
.. ipython:: python
761762
762-
# f, g, and h are functions taking and returning ``DataFrames``
763-
>>> f(g(h(df), arg1=1), arg2=2, arg3=3)
763+
def extract_city_name(df):
764+
"""
765+
Chicago, IL -> Chicago for city_name column
766+
"""
767+
df['city_name'] = df['city_and_code'].str.split(",").str.get(0)
768+
return df
764769
765-
with the equivalent
770+
def add_country_name(df, country_name=None):
771+
"""
772+
Chicago -> Chicago-US for city_name column
773+
"""
774+
col = 'city_name'
775+
df['city_and_country'] = df[col] + country_name
776+
return df
766777
767-
.. code-block:: python
778+
df_p = pd.DataFrame({'city_and_code': ['Chicago, IL']})
779+
780+
781+
``extract_city_name`` and ``add_country_name`` are functions taking and returning ``DataFrames``.
782+
783+
Now compare the following:
784+
785+
.. ipython:: python
786+
787+
add_country_name(extract_city_name(df_p), country_name='US')
788+
789+
Is equivalent to:
790+
791+
.. ipython:: python
768792
769-
>>> (df.pipe(h)
770-
... .pipe(g, arg1=1)
771-
... .pipe(f, arg2=2, arg3=3))
793+
(df_p.pipe(extract_city_name)
794+
.pipe(add_country_name, country_name="US"))
772795
773796
Pandas encourages the second style, which is known as method chaining.
774797
``pipe`` makes it easy to use your own or another library's functions
775798
in method chains, alongside pandas' methods.
776799

777-
In the example above, the functions ``f``, ``g``, and ``h`` each expected the ``DataFrame`` as the first positional argument.
800+
In the example above, the functions ``extract_city_name`` and ``add_country_name`` each expected a ``DataFrame`` as the first positional argument.
778801
What if the function you wish to apply takes its data as, say, the second argument?
779802
In this case, provide ``pipe`` with a tuple of ``(callable, data_keyword)``.
780803
``.pipe`` will route the ``DataFrame`` to the argument specified in the tuple.

doc/source/getting_started/dsintro.rst

-47
Original file line numberDiff line numberDiff line change
@@ -564,53 +564,6 @@ to a column created earlier in the same :meth:`~DataFrame.assign`.
564564
In the second expression, ``x['C']`` will refer to the newly created column,
565565
that's equal to ``dfa['A'] + dfa['B']``.
566566

567-
To write code compatible with all versions of Python, split the assignment in two.
568-
569-
.. ipython:: python
570-
571-
dependent = pd.DataFrame({"A": [1, 1, 1]})
572-
(dependent.assign(A=lambda x: x['A'] + 1)
573-
.assign(B=lambda x: x['A'] + 2))
574-
575-
.. warning::
576-
577-
Dependent assignment may subtly change the behavior of your code between
578-
Python 3.6 and older versions of Python.
579-
580-
If you wish to write code that supports versions of python before and after 3.6,
581-
you'll need to take care when passing ``assign`` expressions that
582-
583-
* Update an existing column
584-
* Refer to the newly updated column in the same ``assign``
585-
586-
For example, we'll update column "A" and then refer to it when creating "B".
587-
588-
.. code-block:: python
589-
590-
>>> dependent = pd.DataFrame({"A": [1, 1, 1]})
591-
>>> dependent.assign(A=lambda x: x["A"] + 1, B=lambda x: x["A"] + 2)
592-
593-
For Python 3.5 and earlier the expression creating ``B`` refers to the
594-
"old" value of ``A``, ``[1, 1, 1]``. The output is then
595-
596-
.. code-block:: console
597-
598-
A B
599-
0 2 3
600-
1 2 3
601-
2 2 3
602-
603-
For Python 3.6 and later, the expression creating ``A`` refers to the
604-
"new" value of ``A``, ``[2, 2, 2]``, which results in
605-
606-
.. code-block:: console
607-
608-
A B
609-
0 2 4
610-
1 2 4
611-
2 2 4
612-
613-
614567

615568
Indexing / selection
616569
~~~~~~~~~~~~~~~~~~~~

doc/source/getting_started/install.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Instructions for installing from source,
1818
Python version support
1919
----------------------
2020

21-
Officially Python 3.5.3 and above, 3.6, 3.7, and 3.8.
21+
Officially Python 3.6.1 and above, 3.7, and 3.8.
2222

2323
Installing pandas
2424
-----------------
@@ -140,7 +140,7 @@ Installing with ActivePython
140140
Installation instructions for
141141
`ActivePython <https://www.activestate.com/activepython>`__ can be found
142142
`here <https://www.activestate.com/activepython/downloads>`__. Versions
143-
2.7 and 3.5 include pandas.
143+
2.7, 3.5 and 3.6 include pandas.
144144

145145
Installing using your Linux distribution's package manager.
146146
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -218,7 +218,7 @@ Recommended dependencies
218218
``numexpr`` uses multiple cores as well as smart chunking and caching to achieve large speedups.
219219
If installed, must be Version 2.6.2 or higher.
220220

221-
* `bottleneck <https://github.com/kwgoodman/bottleneck>`__: for accelerating certain types of ``nan``
221+
* `bottleneck <https://github.com/pydata/bottleneck>`__: for accelerating certain types of ``nan``
222222
evaluations. ``bottleneck`` uses specialized cython routines to achieve large speedups. If installed,
223223
must be Version 1.2.1 or higher.
224224

doc/source/reference/indexing.rst

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ Compatibility with MultiIndex
9393
:toctree: api/
9494

9595
Index.set_names
96-
Index.is_lexsorted_for_tuple
9796
Index.droplevel
9897

9998
Missing values

doc/source/reference/window.rst

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Standard moving window functions
3434
Rolling.quantile
3535
Window.mean
3636
Window.sum
37+
Window.var
38+
Window.std
3739

3840
.. _api.functions_expanding:
3941

0 commit comments

Comments
 (0)