Skip to content

Commit 64abe4c

Browse files
committed
Merge branch 'master' into 2d-object-dont-copy
2 parents 570dbe1 + f8696d5 commit 64abe4c

Some content is hidden

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

67 files changed

+702
-478
lines changed

ci/deps/actions-37-db-min.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.21
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0

ci/deps/actions-37-db.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.21
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-xdist>=1.21
1111
- hypothesis>=3.58.0
1212
- pytest-cov>=2.10.1 # this is only needed in the coverage build, ref: GH 35737
@@ -25,7 +25,7 @@ dependencies:
2525
- flask
2626
- nomkl
2727
- numexpr
28-
- numpy=1.16.*
28+
- numpy=1.17.*
2929
- odfpy
3030
- openpyxl
3131
- pandas-gbq

ci/deps/actions-37-locale_slow.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.21
10-
- pytest>=5.0.1
10+
- pytest>=6.0
1111
- pytest-cov
1212
- pytest-xdist>=1.21
1313
- hypothesis>=3.58.0
@@ -17,13 +17,13 @@ dependencies:
1717
- bottleneck=1.2.*
1818
- lxml
1919
- matplotlib=3.0.0
20-
- numpy=1.16.*
20+
- numpy=1.17.*
2121
- openpyxl=3.0.0
2222
- python-dateutil
2323
- python-blosc
2424
- pytz=2017.3
2525
- scipy
26-
- sqlalchemy=1.2.8
26+
- sqlalchemy=1.3.0
2727
- xlrd=1.2.0
2828
- xlsxwriter=1.0.2
2929
- xlwt=1.3.0

ci/deps/actions-37-slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.21
10-
- pytest>=5.0.1
10+
- pytest>=6.0
1111
- pytest-cov
1212
- pytest-xdist>=1.21
1313
- hypothesis>=3.58.0

ci/deps/actions-37.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.21
10-
- pytest>=5.0.1
10+
- pytest>=6.0
1111
- pytest-cov
1212
- pytest-xdist>=1.21
1313
- hypothesis>=3.58.0

ci/deps/actions-38-locale.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.21
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.21
1212
- pytest-asyncio>=0.12.0
@@ -20,7 +20,7 @@ dependencies:
2020
- jinja2
2121
- jedi<0.18.0
2222
- lxml
23-
- matplotlib <3.3.0
23+
- matplotlib<3.3.0
2424
- moto
2525
- nomkl
2626
- numexpr

ci/deps/actions-38-numpydev.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ dependencies:
55
- python=3.8.*
66

77
# tools
8-
- pytest>=5.0.1
8+
- pytest>=6.0
99
- pytest-cov
1010
- pytest-xdist>=1.21
1111
- hypothesis>=3.58.0
1212

1313
# pandas dependencies
1414
- pytz
15-
- pip=20.2
15+
- pip
1616
- pip:
1717
- cython==0.29.21 # GH#34014
1818
- "git+git://github.com/dateutil/dateutil.git"

ci/deps/actions-38-slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.21
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0

ci/deps/actions-38.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.21
10-
- pytest>=5.0.1
10+
- pytest>=6.0
1111
- pytest-cov
1212
- pytest-xdist>=1.21
1313
- hypothesis>=3.58.0

ci/deps/actions-39.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.21
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0

ci/deps/azure-macos-37.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- python=3.7.*
77

88
# tools
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-xdist>=1.21
1111
- hypothesis>=3.58.0
1212
- pytest-azurepipelines

ci/deps/azure-windows-37.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.21
10-
- pytest>=5.0.1
10+
- pytest>=6.0
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0
1313
- pytest-azurepipelines

ci/deps/azure-windows-38.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# tools
99
- cython>=0.29.21
10-
- pytest>=5.0.1
10+
- pytest>=6.0
1111
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0
1313
- pytest-azurepipelines

ci/deps/travis-37-arm64.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# tools
88
- cython>=0.29.21
9-
- pytest>=5.0.1
9+
- pytest>=6.0
1010
- pytest-xdist>=1.21
1111
- hypothesis>=3.58.0
1212

doc/source/_static/style/tg_ax0.png

12.7 KB
Loading
13.2 KB
Loading
13.4 KB
Loading
13.3 KB
Loading
12.5 KB
Loading

doc/source/_static/style/tg_gmap.png

12.3 KB
Loading

doc/source/reference/style.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Builtin styles
5656
Styler.highlight_min
5757
Styler.highlight_between
5858
Styler.background_gradient
59+
Styler.text_gradient
5960
Styler.bar
6061

6162
Style export and import

doc/source/user_guide/io.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The pandas I/O API is a set of top level ``reader`` functions accessed like
2222
text;Fixed-Width Text File;:ref:`read_fwf<io.fwf_reader>`
2323
text;`JSON <https://www.json.org/>`__;:ref:`read_json<io.json_reader>`;:ref:`to_json<io.json_writer>`
2424
text;`HTML <https://en.wikipedia.org/wiki/HTML>`__;:ref:`read_html<io.read_html>`;:ref:`to_html<io.html>`
25+
text;`LaTeX <https://en.wikipedia.org/wiki/LaTeX>`__;;:ref:`Styler.to_latex<io.latex>`
2526
text;`XML <https://www.w3.org/standards/xml/core>`__;:ref:`read_xml<io.read_xml>`;:ref:`to_xml<io.xml>`
2627
text; Local clipboard;:ref:`read_clipboard<io.clipboard>`;:ref:`to_clipboard<io.clipboard>`
2728
binary;`MS Excel <https://en.wikipedia.org/wiki/Microsoft_Excel>`__;:ref:`read_excel<io.excel_reader>`;:ref:`to_excel<io.excel_writer>`
@@ -2830,7 +2831,42 @@ parse HTML tables in the top-level pandas io function ``read_html``.
28302831
.. |lxml| replace:: **lxml**
28312832
.. _lxml: https://lxml.de
28322833

2834+
.. _io.latex:
28332835

2836+
LaTeX
2837+
-----
2838+
2839+
.. versionadded:: 1.3.0
2840+
2841+
Currently there are no methods to read from LaTeX, only output methods.
2842+
2843+
Writing to LaTeX files
2844+
''''''''''''''''''''''
2845+
2846+
.. note::
2847+
2848+
DataFrame *and* Styler objects currently have a ``to_latex`` method. We recommend
2849+
using the `Styler.to_latex() <../reference/api/pandas.io.formats.style.Styler.to_latex.rst>`__ method
2850+
over `DataFrame.to_latex() <../reference/api/pandas.DataFrame.to_latex.rst>`__ due to the former's greater flexibility with
2851+
conditional styling, and the latter's possible future deprecation.
2852+
2853+
Review the documentation for `Styler.to_latex <../reference/api/pandas.io.formats.style.Styler.to_latex.rst>`__,
2854+
which gives examples of conditional styling and explains the operation of its keyword
2855+
arguments.
2856+
2857+
For simple application the following pattern is sufficient.
2858+
2859+
.. ipython:: python
2860+
2861+
df = pd.DataFrame([[1, 2], [3, 4]], index=["a", "b"], columns=["c", "d"])
2862+
print(df.style.to_latex())
2863+
2864+
To format values before output, chain the `Styler.format <../reference/api/pandas.io.formats.style.Styler.format.rst>`__
2865+
method.
2866+
2867+
.. ipython:: python
2868+
2869+
print(df.style.format("{}").to_latex())
28342870
28352871
XML
28362872
---

doc/source/user_guide/style.ipynb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,8 @@
10121012
" - [.highlight_min][minfunc] and [.highlight_max][maxfunc]: for use with identifying extremeties in data.\n",
10131013
" - [.highlight_between][betweenfunc] and [.highlight_quantile][quantilefunc]: for use with identifying classes within data.\n",
10141014
" - [.background_gradient][bgfunc]: a flexible method for highlighting cells based or their, or other, values on a numeric scale.\n",
1015-
" - [.bar][barfunc]: to display mini-charts within cell backgrounds.\n",
1015+
" - [.text_gradient][textfunc]: similar method for highlighting text based on their, or other, values on a numeric scale.\n",
1016+
" - [.bar][barfunc]: to display mini-charts within cell backgrounds.\n",
10161017
" \n",
10171018
"The individual documentation on each function often gives more examples of their arguments.\n",
10181019
"\n",
@@ -1022,6 +1023,7 @@
10221023
"[betweenfunc]: ../reference/api/pandas.io.formats.style.Styler.highlight_between.rst\n",
10231024
"[quantilefunc]: ../reference/api/pandas.io.formats.style.Styler.highlight_quantile.rst\n",
10241025
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst\n",
1026+
"[textfunc]: ../reference/api/pandas.io.formats.style.Styler.text_gradient.rst\n",
10251027
"[barfunc]: ../reference/api/pandas.io.formats.style.Styler.bar.rst"
10261028
]
10271029
},
@@ -1098,14 +1100,14 @@
10981100
"cell_type": "markdown",
10991101
"metadata": {},
11001102
"source": [
1101-
"### Background Gradient"
1103+
"### Background Gradient and Text Gradient"
11021104
]
11031105
},
11041106
{
11051107
"cell_type": "markdown",
11061108
"metadata": {},
11071109
"source": [
1108-
"You can create \"heatmaps\" with the `background_gradient` method. These require matplotlib, and we'll use [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/) to get a nice colormap."
1110+
"You can create \"heatmaps\" with the `background_gradient` and `text_gradient` methods. These require matplotlib, and we'll use [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/) to get a nice colormap."
11091111
]
11101112
},
11111113
{
@@ -1120,19 +1122,31 @@
11201122
"df2.style.background_gradient(cmap=cm)"
11211123
]
11221124
},
1125+
{
1126+
"cell_type": "code",
1127+
"execution_count": null,
1128+
"metadata": {},
1129+
"outputs": [],
1130+
"source": [
1131+
"df2.style.text_gradient(cmap=cm)"
1132+
]
1133+
},
11231134
{
11241135
"cell_type": "markdown",
11251136
"metadata": {},
11261137
"source": [
1127-
"[.background_gradient][bgfunc] has a number of keyword arguments to customise the gradients and colors. See its documentation.\n",
1138+
"[.background_gradient][bgfunc] and [.text_gradient][textfunc] have a number of keyword arguments to customise the gradients and colors. See the documentation.\n",
11281139
"\n",
1129-
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst"
1140+
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst\n",
1141+
"[textfunc]: ../reference/api/pandas.io.formats.style.Styler.text_gradient.rst"
11301142
]
11311143
},
11321144
{
11331145
"cell_type": "markdown",
11341146
"metadata": {},
11351147
"source": [
1148+
"### Set properties\n",
1149+
"\n",
11361150
"Use `Styler.set_properties` when the style doesn't actually depend on the values. This is just a simple wrapper for `.applymap` where the function returns the same properties for all cells."
11371151
]
11381152
},

doc/source/whatsnew/v1.3.0.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ to allow custom CSS highlighting instead of default background coloring (:issue:
120120
Enhancements to other built-in methods include extending the :meth:`.Styler.background_gradient`
121121
method to shade elements based on a given gradient map and not be restricted only to
122122
values in the DataFrame (:issue:`39930` :issue:`22727` :issue:`28901`). Additional
123-
built-in methods such as :meth:`.Styler.highlight_between` and :meth:`.Styler.highlight_quantile`
124-
have been added (:issue:`39821` and :issue:`40926`).
123+
built-in methods such as :meth:`.Styler.highlight_between`, :meth:`.Styler.highlight_quantile`
124+
and :math:`.Styler.text_gradient` have been added (:issue:`39821`, :issue:`40926`, :issue:`41098`).
125125

126126
The :meth:`.Styler.apply` now consistently allows functions with ``ndarray`` output to
127127
allow more flexible development of UDFs when ``axis`` is ``None`` ``0`` or ``1`` (:issue:`39393`).
@@ -618,7 +618,7 @@ Optional libraries below the lowest tested version may still work, but are not c
618618
+-----------------+-----------------+---------+
619619
| scipy | 1.2.0 | |
620620
+-----------------+-----------------+---------+
621-
| sqlalchemy | 1.2.8 | |
621+
| sqlalchemy | 1.3.0 | X |
622622
+-----------------+-----------------+---------+
623623
| tabulate | 0.8.7 | X |
624624
+-----------------+-----------------+---------+
@@ -655,6 +655,7 @@ Build
655655
Deprecations
656656
~~~~~~~~~~~~
657657
- Deprecated allowing scalars to be passed to the :class:`Categorical` constructor (:issue:`38433`)
658+
- Deprecated constructing :class:`CategoricalIndex` without passing list-like data (:issue:`38944`)
658659
- Deprecated allowing subclass-specific keyword arguments in the :class:`Index` constructor, use the specific subclass directly instead (:issue:`14093`, :issue:`21311`, :issue:`22315`, :issue:`26974`)
659660
- Deprecated ``astype`` of datetimelike (``timedelta64[ns]``, ``datetime64[ns]``, ``Datetime64TZDtype``, ``PeriodDtype``) to integer dtypes, use ``values.view(...)`` instead (:issue:`38544`)
660661
- Deprecated :meth:`MultiIndex.is_lexsorted` and :meth:`MultiIndex.lexsort_depth`, use :meth:`MultiIndex.is_monotonic_increasing` instead (:issue:`32259`)
@@ -832,6 +833,7 @@ Strings
832833
- Bug in the conversion from ``pyarrow.ChunkedArray`` to :class:`~arrays.StringArray` when the original had zero chunks (:issue:`41040`)
833834
- Bug in :meth:`Series.replace` and :meth:`DataFrame.replace` ignoring replacements with ``regex=True`` for ``StringDType`` data (:issue:`41333`, :issue:`35977`)
834835
- Bug in :meth:`Series.str.extract` with :class:`~arrays.StringArray` returning object dtype for empty :class:`DataFrame` (:issue:`41441`)
836+
- Bug in :meth:`Series.str.replace` where the ``case`` argument was ignored when ``regex=False`` (:issue:`41602`)
835837

836838
Interval
837839
^^^^^^^^
@@ -845,6 +847,7 @@ Indexing
845847

846848
- Bug in :meth:`Index.union` dropping duplicate ``Index`` values when ``Index`` was not monotonic or ``sort`` was set to ``False`` (:issue:`36289`, :issue:`31326`, :issue:`40862`)
847849
- Bug in :meth:`CategoricalIndex.get_indexer` failing to raise ``InvalidIndexError`` when non-unique (:issue:`38372`)
850+
- Bug in :meth:`Series.loc` raising ``ValueError`` when input was filtered with a boolean list and values to set were a list with lower dimension (:issue:`20438`)
848851
- Bug in inserting many new columns into a :class:`DataFrame` causing incorrect subsequent indexing behavior (:issue:`38380`)
849852
- Bug in :meth:`DataFrame.__setitem__` raising ``ValueError`` when setting multiple values to duplicate columns (:issue:`15695`)
850853
- Bug in :meth:`DataFrame.loc`, :meth:`Series.loc`, :meth:`DataFrame.__getitem__` and :meth:`Series.__getitem__` returning incorrect elements for non-monotonic :class:`DatetimeIndex` for string slices (:issue:`33146`)
@@ -873,6 +876,7 @@ Indexing
873876
- Bug in :meth:`DataFrame.__setitem__` and :meth:`DataFrame.iloc.__setitem__` raising ``ValueError`` when trying to index with a row-slice and setting a list as values (:issue:`40440`)
874877
- Bug in :meth:`DataFrame.loc` not raising ``KeyError`` when key was not found in :class:`MultiIndex` when levels contain more values than used (:issue:`41170`)
875878
- Bug in :meth:`DataFrame.loc.__setitem__` when setting-with-expansion incorrectly raising when the index in the expanding axis contains duplicates (:issue:`40096`)
879+
- Bug in :meth:`DataFrame.loc.__getitem__` with :class:`MultiIndex` casting to float when at least one column is from has float dtype and we retrieve a scalar (:issue:`41369`)
876880
- Bug in :meth:`DataFrame.loc` incorrectly matching non-boolean index elements (:issue:`20432`)
877881
- Bug in :meth:`Series.__delitem__` with ``ExtensionDtype`` incorrectly casting to ``ndarray`` (:issue:`40386`)
878882
- Bug in :meth:`DataFrame.__setitem__` raising ``TypeError`` when using a str subclass as the column name with a :class:`DatetimeIndex` (:issue:`37366`)
@@ -1056,6 +1060,7 @@ Other
10561060
- Bug in :meth:`DataFrame.agg()` not sorting the aggregated axis in the order of the provided aggragation functions when one or more aggregation function fails to produce results (:issue:`33634`)
10571061
- Bug in :meth:`DataFrame.clip` not interpreting missing values as no threshold (:issue:`40420`)
10581062
- Bug in :class:`Series` backed by :class:`DatetimeArray` or :class:`TimedeltaArray` sometimes failing to set the array's ``freq`` to ``None`` (:issue:`41425`)
1063+
- Bug in creating a :class:`Series` from a ``range`` object that does not fit in the bounds of ``int64`` dtype (:issue:`30173`)
10591064

10601065
.. ---------------------------------------------------------------------------
10611066

pandas/compat/_optional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
"openpyxl": "3.0.0",
2323
"pandas_gbq": "0.12.0",
2424
"pyarrow": "0.17.0",
25-
"pytest": "5.0.1",
25+
"pytest": "6.0",
2626
"pyxlsb": "1.0.6",
2727
"s3fs": "0.4.0",
2828
"scipy": "1.2.0",
29-
"sqlalchemy": "1.2.8",
29+
"sqlalchemy": "1.3.0",
3030
"tables": "3.5.1",
3131
"tabulate": "0.8.7",
3232
"xarray": "0.12.3",

0 commit comments

Comments
 (0)