Skip to content

Commit 26494c1

Browse files
authored
Merge pull request #174 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents adc9703 + 88df92f commit 26494c1

File tree

100 files changed

+1619
-783
lines changed

Some content is hidden

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

100 files changed

+1619
-783
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
minimum_pre_commit_version: 2.9.2
22
exclude: ^LICENSES/|\.(html|csv|svg)$
3+
ci:
4+
autofix_prs: false
35
repos:
46
- repo: https://github.com/MarcoGorelli/absolufy-imports
57
rev: v0.3.0

.travis.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,9 @@ matrix:
3535
fast_finish: true
3636

3737
include:
38-
- arch: arm64
38+
- arch: arm64-graviton2
3939
env:
40-
- 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)"
41-
42-
allow_failures:
43-
# Moved to allowed_failures 2020-09-29 due to timeouts https://github.com/pandas-dev/pandas/issues/36719
44-
- arch: arm64
45-
env:
46-
- 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)"
47-
40+
- JOB="3.7, arm64" PYTEST_WORKERS="auto" ENV_FILE="ci/deps/travis-37-arm64.yaml" PATTERN="(not slow and not network and not clipboard and not arm_slow)"
4841

4942
before_install:
5043
- echo "before_install"

asv_bench/benchmarks/groupby.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,19 @@ class GroupByCythonAgg:
480480
param_names = ["dtype", "method"]
481481
params = [
482482
["float64"],
483-
["sum", "prod", "min", "max", "mean", "median", "var", "first", "last"],
483+
[
484+
"sum",
485+
"prod",
486+
"min",
487+
"max",
488+
"mean",
489+
"median",
490+
"var",
491+
"first",
492+
"last",
493+
"any",
494+
"all",
495+
],
484496
]
485497

486498
def setup(self, dtype, method):

doc/_templates/sidebar-nav-bs.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
2+
<div class="bd-toc-item active">
3+
{% if pagename.startswith("reference") %}
4+
{{ generate_nav_html("sidebar", maxdepth=4, collapse=True, includehidden=True, titles_only=True) }}
5+
{% else %}
6+
{{ generate_nav_html("sidebar", maxdepth=4, collapse=False, includehidden=True, titles_only=True) }}
7+
{% endif %}
8+
</div>
9+
</nav>
7.14 KB
Loading
7.33 KB
Loading
7.59 KB
Loading
7.1 KB
Loading

doc/source/reference/style.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Styler properties
2323
:toctree: api/
2424

2525
Styler.env
26-
Styler.template
26+
Styler.template_html
2727
Styler.loader
2828

2929
Style application
@@ -53,6 +53,7 @@ Builtin styles
5353
Styler.highlight_null
5454
Styler.highlight_max
5555
Styler.highlight_min
56+
Styler.highlight_between
5657
Styler.background_gradient
5758
Styler.bar
5859

doc/source/user_guide/advanced.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ values across a level. For instance:
498498
)
499499
df = pd.DataFrame(np.random.randn(4, 2), index=midx)
500500
df
501-
df2 = df.mean(level=0)
501+
df2 = df.groupby(level=0).mean()
502502
df2
503503
df2.reindex(df.index, level=0)
504504

doc/source/user_guide/categorical.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ even if some categories are not present in the data:
633633
data=[[1, 2, 3], [4, 5, 6]],
634634
columns=pd.MultiIndex.from_arrays([["A", "B", "B"], columns]),
635635
)
636-
df.sum(axis=1, level=1)
636+
df.groupby(axis=1, level=1).sum()
637637
638638
Groupby will also show "unused" categories:
639639

doc/source/user_guide/groupby.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,6 @@ number:
320320
321321
s.groupby(level="second").sum()
322322
323-
The aggregation functions such as ``sum`` will take the level parameter
324-
directly. Additionally, the resulting index will be named according to the
325-
chosen level:
326-
327-
.. ipython:: python
328-
329-
s.sum(level="second")
330-
331323
Grouping with multiple levels is supported.
332324

333325
.. ipython:: python

doc/source/user_guide/style.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@
17101710
" Styler.loader, # the default\n",
17111711
" ])\n",
17121712
" )\n",
1713-
" template = env.get_template(\"myhtml.tpl\")"
1713+
" template_html = env.get_template(\"myhtml.tpl\")"
17141714
]
17151715
},
17161716
{

doc/source/whatsnew/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Version 1.2
2424
.. toctree::
2525
:maxdepth: 2
2626

27+
v1.2.5
2728
v1.2.4
2829
v1.2.3
2930
v1.2.2

doc/source/whatsnew/v0.15.2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Other enhancements:
154154
- ``Series.all`` and ``Series.any`` now support the ``level`` and ``skipna`` parameters (:issue:`8302`):
155155

156156
.. ipython:: python
157+
:okwarning:
157158
158159
s = pd.Series([False, True, False], index=[0, 0, 1])
159160
s.any(level=0)

doc/source/whatsnew/v1.2.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ Fixed regressions
3030
Contributors
3131
~~~~~~~~~~~~
3232

33-
.. contributors:: v1.2.3..v1.2.4|HEAD
33+
.. contributors:: v1.2.3..v1.2.4

doc/source/whatsnew/v1.2.5.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _whatsnew_125:
2+
3+
What's new in 1.2.5 (May ??, 2021)
4+
----------------------------------
5+
6+
These are the changes in pandas 1.2.5. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
{{ header }}
10+
11+
.. ---------------------------------------------------------------------------
12+
13+
.. _whatsnew_125.regressions:
14+
15+
Fixed regressions
16+
~~~~~~~~~~~~~~~~~
17+
18+
-
19+
-
20+
21+
.. ---------------------------------------------------------------------------
22+
23+
.. _whatsnew_125.bug_fixes:
24+
25+
Bug fixes
26+
~~~~~~~~~
27+
28+
-
29+
-
30+
31+
.. ---------------------------------------------------------------------------
32+
33+
.. _whatsnew_125.other:
34+
35+
Other
36+
~~~~~
37+
38+
-
39+
-
40+
41+
.. ---------------------------------------------------------------------------
42+
43+
.. _whatsnew_125.contributors:
44+
45+
Contributors
46+
~~~~~~~~~~~~
47+
48+
.. contributors:: v1.2.4..v1.2.5|HEAD

doc/source/whatsnew/v1.3.0.rst

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ We provided some focused development on :class:`.Styler`, including altering met
117117
to accept more universal CSS language for arguments, such as ``'color:red;'`` instead of
118118
``[('color', 'red')]`` (:issue:`39564`). This is also added to the built-in methods
119119
to allow custom CSS highlighting instead of default background coloring (:issue:`40242`).
120+
Enhancements to other built-in methods include extending the :meth:`.Styler.background_gradient`
121+
method to shade elements based on a given gradient map and not be restricted only to
122+
values in the DataFrame (:issue:`39930` :issue:`22727` :issue:`28901`).
120123

121124
The :meth:`.Styler.apply` now consistently allows functions with ``ndarray`` output to
122125
allow more flexible development of UDFs when ``axis`` is ``None`` ``0`` or ``1`` (:issue:`39393`).
@@ -206,13 +209,17 @@ Other enhancements
206209
- :meth:`.Styler.background_gradient` now allows the ability to supply a specific gradient map (:issue:`22727`)
207210
- :meth:`.Styler.clear` now clears :attr:`Styler.hidden_index` and :attr:`Styler.hidden_columns` as well (:issue:`40484`)
208211
- Builtin highlighting methods in :class:`Styler` have a more consistent signature and css customisability (:issue:`40242`)
212+
- :meth:`.Styler.highlight_between` added to list of builtin styling methods (:issue:`39821`)
209213
- :meth:`Series.loc.__getitem__` and :meth:`Series.loc.__setitem__` with :class:`MultiIndex` now raising helpful error message when indexer has too many dimensions (:issue:`35349`)
210214
- :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files.
211215
- Add support for parsing ``ISO 8601``-like timestamps with negative signs to :meth:`pandas.Timedelta` (:issue:`37172`)
212216
- Add support for unary operators in :class:`FloatingArray` (:issue:`38749`)
213217
- :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`)
214218
- :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`)
215219
- :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`)
220+
- :meth:`.GroupBy.any` and :meth:`.GroupBy.all` use Kleene logic with nullable data types (:issue:`37506`)
221+
- :meth:`.GroupBy.any` and :meth:`.GroupBy.all` return a ``BooleanDtype`` for columns with nullable data types (:issue:`33449`)
222+
-
216223

217224
.. ---------------------------------------------------------------------------
218225
@@ -563,6 +570,7 @@ Deprecations
563570
- Deprecated allowing partial failure in :meth:`Series.transform` and :meth:`DataFrame.transform` when ``func`` is list-like or dict-like and raises anything but ``TypeError``; ``func`` raising anything but a ``TypeError`` will raise in a future version (:issue:`40211`)
564571
- Deprecated support for ``np.ma.mrecords.MaskedRecords`` in the :class:`DataFrame` constructor, pass ``{name: data[name] for name in data.dtype.names}`` instead (:issue:`40363`)
565572
- Deprecated the use of ``**kwargs`` in :class:`.ExcelWriter`; use the keyword argument ``engine_kwargs`` instead (:issue:`40430`)
573+
- Deprecated the ``level`` keyword for :class:`DataFrame` and :class:`Series` aggregations; use groupby instead (:issue:`39983`)
566574

567575
.. ---------------------------------------------------------------------------
568576
@@ -782,6 +790,8 @@ Groupby/resample/rolling
782790
- Bug in :meth:`Series.asfreq` and :meth:`DataFrame.asfreq` dropping rows when the index is not sorted (:issue:`39805`)
783791
- Bug in aggregation functions for :class:`DataFrame` not respecting ``numeric_only`` argument when ``level`` keyword was given (:issue:`40660`)
784792
- Bug in :class:`core.window.RollingGroupby` where ``as_index=False`` argument in ``groupby`` was ignored (:issue:`39433`)
793+
- Bug in :meth:`.GroupBy.any` and :meth:`.GroupBy.all` raising ``ValueError`` when using with nullable type columns holding ``NA`` even with ``skipna=True`` (:issue:`40585`)
794+
785795

786796
Reshaping
787797
^^^^^^^^^
@@ -818,24 +828,29 @@ ExtensionArray
818828
- Fixed a bug where some properties of subclasses of :class:`PandasExtensionDtype` where improperly cached (:issue:`40329`)
819829
-
820830

831+
Styler
832+
^^^^^^
833+
834+
- Bug in :class:`Styler` where ``subset`` arg in methods raised an error for some valid multiindex slices (:issue:`33562`)
835+
- :class:`Styler` rendered HTML output minor alterations to support w3 good code standard (:issue:`39626`)
836+
- Bug in :class:`Styler` where rendered HTML was missing a column class identifier for certain header cells (:issue:`39716`)
837+
- Bug in :meth:`Styler.background_gradient` where text-color was not determined correctly (:issue:`39888`)
838+
- Bug in :class:`Styler` where multiple elements in CSS-selectors were not correctly added to ``table_styles`` (:issue:`39942`)
839+
- Bug in :class:`.Styler` where copying from Jupyter dropped top left cell and misaligned headers (:issue:`12147`)
840+
- Bug in :class:`.Styler.where` where ``kwargs`` were not passed to the applicable callable (:issue:`40845`)
841+
- Bug in :class:`Styler` which caused CSS to duplicate on multiple renders. (:issue:`39395`, :issue:`40334`)
842+
843+
821844
Other
822845
^^^^^
823846
- Bug in :class:`Index` constructor sometimes silently ignoring a specified ``dtype`` (:issue:`38879`)
824847
- Bug in :func:`pandas.api.types.infer_dtype` not recognizing Series, Index or array with a period dtype (:issue:`23553`)
825848
- Bug in :func:`pandas.api.types.infer_dtype` raising an error for general :class:`.ExtensionArray` objects. It will now return ``"unknown-array"`` instead of raising (:issue:`37367`)
826849
- Bug in constructing a :class:`Series` from a list and a :class:`PandasDtype` (:issue:`39357`)
827-
- Bug in :class:`Styler` which caused CSS to duplicate on multiple renders. (:issue:`39395`, :issue:`40334`)
828850
- ``inspect.getmembers(Series)`` no longer raises an ``AbstractMethodError`` (:issue:`38782`)
829851
- Bug in :meth:`Series.where` with numeric dtype and ``other = None`` not casting to ``nan`` (:issue:`39761`)
830852
- :meth:`Index.where` behavior now mirrors :meth:`Index.putmask` behavior, i.e. ``index.where(mask, other)`` matches ``index.putmask(~mask, other)`` (:issue:`39412`)
831853
- Bug in :func:`pandas.testing.assert_series_equal`, :func:`pandas.testing.assert_frame_equal`, :func:`pandas.testing.assert_index_equal` and :func:`pandas.testing.assert_extension_array_equal` incorrectly raising when an attribute has an unrecognized NA type (:issue:`39461`)
832-
- Bug in :class:`Styler` where ``subset`` arg in methods raised an error for some valid multiindex slices (:issue:`33562`)
833-
- :class:`Styler` rendered HTML output minor alterations to support w3 good code standard (:issue:`39626`)
834-
- Bug in :class:`Styler` where rendered HTML was missing a column class identifier for certain header cells (:issue:`39716`)
835-
- Bug in :meth:`Styler.background_gradient` where text-color was not determined correctly (:issue:`39888`)
836-
- Bug in :class:`Styler` where multiple elements in CSS-selectors were not correctly added to ``table_styles`` (:issue:`39942`)
837-
- Bug in :class:`.Styler` where copying from Jupyter dropped top left cell and misaligned headers (:issue:`12147`)
838-
- Bug in :class:`.Styler.where` where ``kwargs`` were not passed to the applicable callable (:issue:`40845`)
839854
- Bug in :meth:`DataFrame.equals`, :meth:`Series.equals`, :meth:`Index.equals` with object-dtype containing ``np.datetime64("NaT")`` or ``np.timedelta64("NaT")`` (:issue:`39650`)
840855
- Bug in :func:`pandas.util.show_versions` where console JSON output was not proper JSON (:issue:`39701`)
841856
- Bug in :meth:`DataFrame.convert_dtypes` incorrectly raised ValueError when called on an empty DataFrame (:issue:`40393`)

pandas/_config/config.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
4949
"""
5050

51+
from __future__ import annotations
52+
5153
from collections import namedtuple
5254
from contextlib import (
5355
ContextDecorator,
@@ -57,12 +59,7 @@
5759
from typing import (
5860
Any,
5961
Callable,
60-
Dict,
6162
Iterable,
62-
List,
63-
Optional,
64-
Tuple,
65-
Type,
6663
cast,
6764
)
6865
import warnings
@@ -73,16 +70,16 @@
7370
RegisteredOption = namedtuple("RegisteredOption", "key defval doc validator cb")
7471

7572
# holds deprecated option metadata
76-
_deprecated_options: Dict[str, DeprecatedOption] = {}
73+
_deprecated_options: dict[str, DeprecatedOption] = {}
7774

7875
# holds registered option metadata
79-
_registered_options: Dict[str, RegisteredOption] = {}
76+
_registered_options: dict[str, RegisteredOption] = {}
8077

8178
# holds the current values for registered options
82-
_global_config: Dict[str, Any] = {}
79+
_global_config: dict[str, Any] = {}
8380

8481
# keys which have a special meaning
85-
_reserved_keys: List[str] = ["all"]
82+
_reserved_keys: list[str] = ["all"]
8683

8784

8885
class OptionError(AttributeError, KeyError):
@@ -194,7 +191,7 @@ def get_default_val(pat: str):
194191
class DictWrapper:
195192
""" provide attribute-style access to a nested dict"""
196193

197-
def __init__(self, d: Dict[str, Any], prefix: str = ""):
194+
def __init__(self, d: dict[str, Any], prefix: str = ""):
198195
object.__setattr__(self, "d", d)
199196
object.__setattr__(self, "prefix", prefix)
200197

@@ -428,8 +425,8 @@ def register_option(
428425
key: str,
429426
defval: object,
430427
doc: str = "",
431-
validator: Optional[Callable[[Any], Any]] = None,
432-
cb: Optional[Callable[[str], Any]] = None,
428+
validator: Callable[[Any], Any] | None = None,
429+
cb: Callable[[str], Any] | None = None,
433430
) -> None:
434431
"""
435432
Register an option in the package-wide pandas config object
@@ -500,7 +497,7 @@ def register_option(
500497

501498

502499
def deprecate_option(
503-
key: str, msg: Optional[str] = None, rkey: Optional[str] = None, removal_ver=None
500+
key: str, msg: str | None = None, rkey: str | None = None, removal_ver=None
504501
) -> None:
505502
"""
506503
Mark option `key` as deprecated, if code attempts to access this option,
@@ -547,7 +544,7 @@ def deprecate_option(
547544
# functions internal to the module
548545

549546

550-
def _select_options(pat: str) -> List[str]:
547+
def _select_options(pat: str) -> list[str]:
551548
"""
552549
returns a list of keys matching `pat`
553550
@@ -565,7 +562,7 @@ def _select_options(pat: str) -> List[str]:
565562
return [k for k in keys if re.search(pat, k, re.I)]
566563

567564

568-
def _get_root(key: str) -> Tuple[Dict[str, Any], str]:
565+
def _get_root(key: str) -> tuple[dict[str, Any], str]:
569566
path = key.split(".")
570567
cursor = _global_config
571568
for p in path[:-1]:
@@ -674,7 +671,7 @@ def pp_options_list(keys: Iterable[str], width=80, _print: bool = False):
674671
from itertools import groupby
675672
from textwrap import wrap
676673

677-
def pp(name: str, ks: Iterable[str]) -> List[str]:
674+
def pp(name: str, ks: Iterable[str]) -> list[str]:
678675
pfx = "- " + name + ".[" if name else ""
679676
ls = wrap(
680677
", ".join(ks),
@@ -687,7 +684,7 @@ def pp(name: str, ks: Iterable[str]) -> List[str]:
687684
ls[-1] = ls[-1] + "]"
688685
return ls
689686

690-
ls: List[str] = []
687+
ls: list[str] = []
691688
singles = [x for x in sorted(keys) if x.find(".") < 0]
692689
if singles:
693690
ls += pp("", singles)
@@ -760,7 +757,7 @@ def inner(key: str, *args, **kwds):
760757
# arg in register_option
761758

762759

763-
def is_type_factory(_type: Type[Any]) -> Callable[[Any], None]:
760+
def is_type_factory(_type: type[Any]) -> Callable[[Any], None]:
764761
"""
765762
766763
Parameters
@@ -826,7 +823,7 @@ def inner(x) -> None:
826823
return inner
827824

828825

829-
def is_nonnegative_int(value: Optional[int]) -> None:
826+
def is_nonnegative_int(value: int | None) -> None:
830827
"""
831828
Verify that value is None or a positive int.
832829

0 commit comments

Comments
 (0)