Skip to content

Commit 383202b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into mask_pos_args_deprecation
2 parents fcc9b70 + 0bc1698 commit 383202b

Some content is hidden

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

62 files changed

+473
-267
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/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: 7 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`)
@@ -845,6 +846,7 @@ Indexing
845846

846847
- 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`)
847848
- Bug in :meth:`CategoricalIndex.get_indexer` failing to raise ``InvalidIndexError`` when non-unique (:issue:`38372`)
849+
- 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`)
848850
- Bug in inserting many new columns into a :class:`DataFrame` causing incorrect subsequent indexing behavior (:issue:`38380`)
849851
- Bug in :meth:`DataFrame.__setitem__` raising ``ValueError`` when setting multiple values to duplicate columns (:issue:`15695`)
850852
- 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 +875,7 @@ Indexing
873875
- 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`)
874876
- 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`)
875877
- Bug in :meth:`DataFrame.loc.__setitem__` when setting-with-expansion incorrectly raising when the index in the expanding axis contains duplicates (:issue:`40096`)
878+
- 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`)
876879
- Bug in :meth:`DataFrame.loc` incorrectly matching non-boolean index elements (:issue:`20432`)
877880
- Bug in :meth:`Series.__delitem__` with ``ExtensionDtype`` incorrectly casting to ``ndarray`` (:issue:`40386`)
878881
- Bug in :meth:`DataFrame.__setitem__` raising ``TypeError`` when using a str subclass as the column name with a :class:`DatetimeIndex` (:issue:`37366`)
@@ -1056,6 +1059,7 @@ Other
10561059
- 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`)
10571060
- Bug in :meth:`DataFrame.clip` not interpreting missing values as no threshold (:issue:`40420`)
10581061
- Bug in :class:`Series` backed by :class:`DatetimeArray` or :class:`TimedeltaArray` sometimes failing to set the array's ``freq`` to ``None`` (:issue:`41425`)
1062+
- Bug in creating a :class:`Series` from a ``range`` object that does not fit in the bounds of ``int64`` dtype (:issue:`30173`)
10591063

10601064
.. ---------------------------------------------------------------------------
10611065

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",

pandas/compat/numpy/function.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
Union,
2323
)
2424

25-
from numpy import (
26-
__version__,
27-
ndarray,
28-
)
25+
from numpy import ndarray
2926

3027
from pandas._libs.lib import (
3128
is_bool,
@@ -38,8 +35,6 @@
3835
validate_kwargs,
3936
)
4037

41-
from pandas.util.version import Version
42-
4338

4439
class CompatValidator:
4540
def __init__(
@@ -128,10 +123,7 @@ def validate_argmax_with_skipna(skipna, args, kwargs):
128123
ARGSORT_DEFAULTS["axis"] = -1
129124
ARGSORT_DEFAULTS["kind"] = "quicksort"
130125
ARGSORT_DEFAULTS["order"] = None
131-
132-
if Version(__version__) >= Version("1.17.0"):
133-
# GH-26361. NumPy added radix sort and changed default to None.
134-
ARGSORT_DEFAULTS["kind"] = None
126+
ARGSORT_DEFAULTS["kind"] = None
135127

136128

137129
validate_argsort = CompatValidator(

pandas/core/arrays/datetimes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,14 +1119,14 @@ def to_period(self, freq=None) -> PeriodArray:
11191119
... "2000-08-31 00:00:00"]))
11201120
>>> df.index.to_period("M")
11211121
PeriodIndex(['2000-03', '2000-05', '2000-08'],
1122-
dtype='period[M]', freq='M')
1122+
dtype='period[M]')
11231123
11241124
Infer the daily frequency
11251125
11261126
>>> idx = pd.date_range("2017-01-01", periods=2)
11271127
>>> idx.to_period()
11281128
PeriodIndex(['2017-01-01', '2017-01-02'],
1129-
dtype='period[D]', freq='D')
1129+
dtype='period[D]')
11301130
"""
11311131
from pandas.core.arrays import PeriodArray
11321132

pandas/core/arrays/period.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,15 @@ def asfreq(self, freq=None, how: str = "E") -> PeriodArray:
564564
>>> pidx = pd.period_range('2010-01-01', '2015-01-01', freq='A')
565565
>>> pidx
566566
PeriodIndex(['2010', '2011', '2012', '2013', '2014', '2015'],
567-
dtype='period[A-DEC]', freq='A-DEC')
567+
dtype='period[A-DEC]')
568568
569569
>>> pidx.asfreq('M')
570570
PeriodIndex(['2010-12', '2011-12', '2012-12', '2013-12', '2014-12',
571-
'2015-12'], dtype='period[M]', freq='M')
571+
'2015-12'], dtype='period[M]')
572572
573573
>>> pidx.asfreq('M', how='S')
574574
PeriodIndex(['2010-01', '2011-01', '2012-01', '2013-01', '2014-01',
575-
'2015-01'], dtype='period[M]', freq='M')
575+
'2015-01'], dtype='period[M]')
576576
"""
577577
how = libperiod.validate_end_alias(how)
578578

0 commit comments

Comments
 (0)