From 418cc6068aeb4618683c0d79afc3b7f8b5a88c67 Mon Sep 17 00:00:00 2001 From: MeeseeksMachine <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 5 Jan 2022 08:13:04 -0800 Subject: [PATCH 001/209] Backport PR #45197: DOC: Increased minimum version for Python (#45200) Co-authored-by: Simon Hawkins --- doc/source/whatsnew/v1.4.0.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 54fb6555fa05d..5e74cf57e8718 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -382,6 +382,13 @@ instead (:issue:`26314`). Backwards incompatible API changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. _whatsnew_140.api_breaking.python: + +Increased minimum version for Python +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +pandas 1.4.0 supports Python 3.8 and higher. + .. _whatsnew_140.api_breaking.deps: Increased minimum versions for dependencies From 667b3a5ab9b211ab58402313fb0846aa0c4f3530 Mon Sep 17 00:00:00 2001 From: MeeseeksMachine <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 5 Jan 2022 10:22:17 -0800 Subject: [PATCH 002/209] Backport PR #45199: CI: activate azure pipelines/github actions on 1.4.x (#45201) Co-authored-by: Simon Hawkins --- .github/workflows/code-checks.yml | 4 ++-- .github/workflows/datamanger.yml | 4 ++-- .github/workflows/docbuild-and-upload.yml | 4 ++-- .github/workflows/posix.yml | 4 ++-- .github/workflows/python-dev.yml | 4 ++-- .github/workflows/sdist.yml | 4 ++-- azure-pipelines.yml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 634688d65e117..6bf3577f2bd3d 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -4,11 +4,11 @@ on: push: branches: - master - - 1.3.x + - 1.4.x pull_request: branches: - master - - 1.3.x + - 1.4.x env: ENV_FILE: environment.yml diff --git a/.github/workflows/datamanger.yml b/.github/workflows/datamanger.yml index d6c96926d0d92..896064e1cccea 100644 --- a/.github/workflows/datamanger.yml +++ b/.github/workflows/datamanger.yml @@ -4,11 +4,11 @@ on: push: branches: - master - - 1.3.x + - 1.4.x pull_request: branches: - master - - 1.3.x + - 1.4.x env: ENV_FILE: environment.yml diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 7f830b59251d1..e9c813a51ff78 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -4,11 +4,11 @@ on: push: branches: - master - - 1.3.x + - 1.4.x pull_request: branches: - master - - 1.3.x + - 1.4.x env: ENV_FILE: environment.yml diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index bc3ee2e500d22..e28878c2a03d8 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -4,11 +4,11 @@ on: push: branches: - master - - 1.3.x + - 1.4.x pull_request: branches: - master - - 1.3.x + - 1.4.x paths-ignore: - "doc/**" diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index a7c7f3b739f65..389607f1b356a 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -4,11 +4,11 @@ on: push: branches: - master - - 1.3.x + - 1.4.x pull_request: branches: - master - - 1.3.x + - 1.4.x paths-ignore: - "doc/**" diff --git a/.github/workflows/sdist.yml b/.github/workflows/sdist.yml index 9ce3cc5d59208..ace22d716e065 100644 --- a/.github/workflows/sdist.yml +++ b/.github/workflows/sdist.yml @@ -4,11 +4,11 @@ on: push: branches: - master - - 1.3.x + - 1.4.x pull_request: branches: - master - - 1.3.x + - 1.4.x paths-ignore: - "doc/**" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ac91dcac4d2d8..6f221cd62797d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ trigger: branches: include: - master - - 1.3.x + - 1.4.x paths: exclude: - 'doc/*' @@ -13,7 +13,7 @@ pr: branches: include: - master - - 1.3.x + - 1.4.x variables: PYTEST_WORKERS: auto From dd9ff440ed78a0a227d1c50bf361b8039a4c16a4 Mon Sep 17 00:00:00 2001 From: MeeseeksMachine <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 5 Jan 2022 12:31:11 -0800 Subject: [PATCH 003/209] Backport PR #45195: BLD: updated pydata-sphinx-theme to master in environment.yml (#45202) Co-authored-by: Prithvijit <71138854+prithvijitguha@users.noreply.github.com> --- environment.yml | 5 +---- requirements-dev.txt | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/environment.yml b/environment.yml index bf317d24122ae..a901d6f2e9f57 100644 --- a/environment.yml +++ b/environment.yml @@ -120,9 +120,6 @@ dependencies: - tabulate>=0.8.3 # DataFrame.to_markdown - natsort # DataFrame.sort_values - pip: - #issue with building environment in conda on windows. Issue: https://github.com/pandas-dev/pandas/issues/45123 - #issue with pydata-sphix-theme on windows. Issue: https://github.com/pydata/pydata-sphinx-theme/issues/523 - #using previous stable version as workaround - - git+https://github.com/pydata/pydata-sphinx-theme.git@41764f5 + - git+https://github.com/pydata/pydata-sphinx-theme.git@master - pandas-dev-flaker==0.2.0 - pytest-cython diff --git a/requirements-dev.txt b/requirements-dev.txt index 17881500bfa0c..b483d72118a3d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -83,7 +83,7 @@ cftime pyreadstat tabulate>=0.8.3 natsort -git+https://github.com/pydata/pydata-sphinx-theme.git@41764f5 +git+https://github.com/pydata/pydata-sphinx-theme.git@master pandas-dev-flaker==0.2.0 pytest-cython setuptools>=51.0.0 From bee33c79bc813f8b5e7f5ce82ab055c4982b1198 Mon Sep 17 00:00:00 2001 From: MeeseeksMachine <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 5 Jan 2022 17:57:56 -0800 Subject: [PATCH 004/209] Backport PR #45205: DOC: fix typo in 06_calculate_statistics (#45213) Co-authored-by: Hiroaki Ogasawara <13391129+xhiroga@users.noreply.github.com> --- .../getting_started/intro_tutorials/06_calculate_statistics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/getting_started/intro_tutorials/06_calculate_statistics.rst b/doc/source/getting_started/intro_tutorials/06_calculate_statistics.rst index fcf754e340ab2..caa37d69f2945 100644 --- a/doc/source/getting_started/intro_tutorials/06_calculate_statistics.rst +++ b/doc/source/getting_started/intro_tutorials/06_calculate_statistics.rst @@ -82,7 +82,7 @@ return a ``DataFrame``, see the :ref:`subset data tutorial <10min_tut_03_subset> The aggregating statistic can be calculated for multiple columns at the -same time. Remember the ``describe`` function from :ref:`first tutorial <10min_tut_01_tableoriented>` tutorial? +same time. Remember the ``describe`` function from :ref:`first tutorial <10min_tut_01_tableoriented>`? .. ipython:: python From 686a66415a99c3e017aa49c135b93f7a2052cb0e Mon Sep 17 00:00:00 2001 From: MeeseeksMachine <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 5 Jan 2022 20:12:54 -0800 Subject: [PATCH 005/209] Backport PR #44894: DOC: `MultiIndex.get_level_values` mentions implicit type casting if level contains null. (#45210) Co-authored-by: Michael Wang --- pandas/core/indexes/multi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 45c386510cc38..7af234ccbd6b0 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1658,6 +1658,12 @@ def get_level_values(self, level): Values is a level of this MultiIndex converted to a single :class:`Index` (or subclass thereof). + Notes + ----- + If the level contains missing values, the result may be casted to + ``float`` with missing values specified as ``NaN``. This is because + the level is converted to a regular ``Index``. + Examples -------- Create a MultiIndex: @@ -1671,6 +1677,16 @@ def get_level_values(self, level): Index(['a', 'b', 'c'], dtype='object', name='level_1') >>> mi.get_level_values('level_2') Index(['d', 'e', 'f'], dtype='object', name='level_2') + + If a level contains missing values, the return type of the level + maybe casted to ``float``. + + >>> pd.MultiIndex.from_arrays([[1, None, 2], [3, 4, 5]]).dtypes + level_0 int64 + level_1 int64 + dtype: object + >>> pd.MultiIndex.from_arrays([[1, None, 2], [3, 4, 5]]).get_level_values(0) + Float64Index([1.0, nan, 2.0], dtype='float64') """ level = self._get_level_number(level) values = self._get_level_values(level) From c17e8ecc4b61068e09d83777b288565f72a5dbec Mon Sep 17 00:00:00 2001 From: MeeseeksMachine <39504233+meeseeksmachine@users.noreply.github.com> Date: Thu, 6 Jan 2022 06:20:07 -0800 Subject: [PATCH 006/209] Backport PR #45138: ENH: add `cline` to `Styler.to_latex` (#45211) Co-authored-by: JHM Darbyshire <24256554+attack68@users.noreply.github.com> --- doc/source/whatsnew/v1.4.0.rst | 1 + pandas/io/formats/style.py | 18 +++ pandas/io/formats/style_render.py | 60 +++++++-- .../io/formats/templates/latex_longtable.tpl | 4 + pandas/io/formats/templates/latex_table.tpl | 4 + .../tests/io/formats/style/test_to_latex.py | 114 ++++++++++++++++++ 6 files changed, 189 insertions(+), 12 deletions(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 5e74cf57e8718..e23b521d47840 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -105,6 +105,7 @@ There are also some LaTeX specific enhancements: - :meth:`.Styler.to_latex` introduces keyword argument ``environment``, which also allows a specific "longtable" entry through a separate jinja2 template (:issue:`41866`). - Naive sparsification is now possible for LaTeX without the necessity of including the multirow package (:issue:`43369`) + - *cline* support has been added for MultiIndex row sparsification through a keyword argument (:issue:`45138`) .. _whatsnew_140.enhancements.pyarrow_csv_engine: diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 2e74ac93b1ced..29c1e35dbb546 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -494,6 +494,7 @@ def to_latex( position: str | None = None, position_float: str | None = None, hrules: bool | None = None, + clines: str | None = None, label: str | None = None, caption: str | tuple | None = None, sparse_index: bool | None = None, @@ -542,6 +543,22 @@ def to_latex( Defaults to ``pandas.options.styler.latex.hrules``, which is `False`. .. versionchanged:: 1.4.0 + clines : str, optional + Use to control adding \\cline commands for the index labels separation. + Possible values are: + + - `None`: no cline commands are added (default). + - `"all;data"`: a cline is added for every index value extending the + width of the table, including data entries. + - `"all;index"`: as above with lines extending only the width of the + index entries. + - `"skip-last;data"`: a cline is added for each index value except the + last level (which is never sparsified), extending the widtn of the + table. + - `"skip-last;index"`: as above with lines extending only the width of the + index entries. + + .. versionadded:: 1.4.0 label : str, optional The LaTeX label included as: \\label{