Skip to content

Commit d9f084e

Browse files
committed
Merge branch 'master' into excel_2blanks
2 parents 2d47483 + 7c71498 commit d9f084e

File tree

111 files changed

+2193
-1903
lines changed

Some content is hidden

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

111 files changed

+2193
-1903
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ repos:
4747
types: [text]
4848
args: [--append-config=flake8/cython-template.cfg]
4949
- repo: https://github.com/PyCQA/isort
50-
rev: 5.7.0
50+
rev: 5.8.0
5151
hooks:
5252
- id: isort
5353
- repo: https://github.com/asottile/pyupgrade
54-
rev: v2.10.0
54+
rev: v2.11.0
5555
hooks:
5656
- id: pyupgrade
5757
args: [--py37-plus, --keep-runtime-typing]

asv_bench/benchmarks/io/style.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pandas import DataFrame
44

55

6-
class RenderApply:
6+
class Render:
77

88
params = [[12, 24, 36], [12, 120]]
99
param_names = ["cols", "rows"]
@@ -14,15 +14,21 @@ def setup(self, cols, rows):
1414
columns=[f"float_{i+1}" for i in range(cols)],
1515
index=[f"row_{i+1}" for i in range(rows)],
1616
)
17-
self._style_apply()
1817

19-
def time_render(self, cols, rows):
18+
def time_apply_render(self, cols, rows):
19+
self._style_apply()
2020
self.st.render()
2121

22-
def peakmem_apply(self, cols, rows):
22+
def peakmem_apply_render(self, cols, rows):
2323
self._style_apply()
24+
self.st.render()
2425

25-
def peakmem_render(self, cols, rows):
26+
def time_classes_render(self, cols, rows):
27+
self._style_classes()
28+
self.st.render()
29+
30+
def peakmem_classes_render(self, cols, rows):
31+
self._style_classes()
2632
self.st.render()
2733

2834
def _style_apply(self):
@@ -32,3 +38,8 @@ def _apply_func(s):
3238
]
3339

3440
self.st = self.df.style.apply(_apply_func, axis=1)
41+
42+
def _style_classes(self):
43+
classes = self.df.applymap(lambda v: ("cls-1" if v > 0 else ""))
44+
classes.index, classes.columns = self.df.index, self.df.columns
45+
self.st = self.df.style.set_td_classes(classes)

ci/code_checks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ import sys
118118
import pandas
119119
120120
blocklist = {'bs4', 'gcsfs', 'html5lib', 'http', 'ipython', 'jinja2', 'hypothesis',
121-
'lxml', 'matplotlib', 'numexpr', 'openpyxl', 'py', 'pytest', 's3fs', 'scipy',
121+
'lxml', 'matplotlib', 'openpyxl', 'py', 'pytest', 's3fs', 'scipy',
122122
'tables', 'urllib.request', 'xlrd', 'xlsxwriter', 'xlwt'}
123123
124124
# GH#28227 for some of these check for top-level modules, while others are

ci/run_tests.sh

+5
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ fi
2929

3030
echo $PYTEST_CMD
3131
sh -c "$PYTEST_CMD"
32+
33+
PYTEST_AM_CMD="PANDAS_DATA_MANAGER=array pytest -m \"$PATTERN and arraymanager\" -n $PYTEST_WORKERS --dist=loadfile -s --strict-markers --durations=30 --junitxml=test-data.xml $TEST_ARGS $COVERAGE pandas"
34+
35+
echo $PYTEST_AM_CMD
36+
sh -c "$PYTEST_AM_CMD"

doc/make.py

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def __init__(
5454

5555
if single_doc:
5656
single_doc = self._process_single_doc(single_doc)
57-
include_api = False
5857
os.environ["SPHINX_PATTERN"] = single_doc
5958
elif not include_api:
6059
os.environ["SPHINX_PATTERN"] = "-api"

doc/source/development/contributing.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ Creating a Python environment (pip)
325325
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326326

327327
If you aren't using conda for your development environment, follow these instructions.
328-
You'll need to have at least Python 3.6.1 installed on your system.
328+
You'll need to have at least Python 3.7.0 installed on your system. If your Python version
329+
is 3.8.0 (or later), you might need to update your ``setuptools`` to version 42.0.0 (or later)
330+
in your development environment before installing the build dependencies::
331+
332+
pip install --upgrade setuptools
329333

330334
**Unix**/**macOS with virtualenv**
331335

doc/source/user_guide/io.rst

+2
Original file line numberDiff line numberDiff line change
@@ -5240,6 +5240,7 @@ Write to a feather file.
52405240
Read from a feather file.
52415241

52425242
.. ipython:: python
5243+
:okwarning:
52435244
52445245
result = pd.read_feather("example.feather")
52455246
result
@@ -5323,6 +5324,7 @@ Write to a parquet file.
53235324
Read from a parquet file.
53245325

53255326
.. ipython:: python
5327+
:okwarning:
53265328
53275329
result = pd.read_parquet("example_fp.parquet", engine="fastparquet")
53285330
result = pd.read_parquet("example_pa.parquet", engine="pyarrow")

doc/source/whatsnew/v1.2.4.rst

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Fixed regressions
1616
~~~~~~~~~~~~~~~~~
1717

1818
- Fixed regression in :meth:`DataFrame.sum` when ``min_count`` greater than the :class:`DataFrame` shape was passed resulted in a ``ValueError`` (:issue:`39738`)
19+
- Fixed regression in :meth:`DataFrame.to_json` raising ``AttributeError`` when run on PyPy (:issue:`39837`)
20+
- Fixed regression in :meth:`DataFrame.where` not returning a copy in the case of an all True condition (:issue:`39595`)
21+
- Fixed regression in :meth:`DataFrame.replace` raising ``IndexError`` when ``regex`` was a multi-key dictionary (:issue:`39338`)
1922
-
2023

2124
.. ---------------------------------------------------------------------------

doc/source/whatsnew/v1.3.0.rst

+24-1
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,15 @@ Other enhancements
128128
- :meth:`.Rolling.sum`, :meth:`.Expanding.sum`, :meth:`.Rolling.mean`, :meth:`.Expanding.mean`, :meth:`.Rolling.median`, :meth:`.Expanding.median`, :meth:`.Rolling.max`, :meth:`.Expanding.max`, :meth:`.Rolling.min`, and :meth:`.Expanding.min` now support ``Numba`` execution with the ``engine`` keyword (:issue:`38895`)
129129
- :meth:`DataFrame.apply` can now accept NumPy unary operators as strings, e.g. ``df.apply("sqrt")``, which was already the case for :meth:`Series.apply` (:issue:`39116`)
130130
- :meth:`DataFrame.apply` can now accept non-callable DataFrame properties as strings, e.g. ``df.apply("size")``, which was already the case for :meth:`Series.apply` (:issue:`39116`)
131+
- :meth:`DataFrame.applymap` can now accept kwargs to pass on to func (:issue:`39987`)
131132
- Disallow :class:`DataFrame` indexer for ``iloc`` for :meth:`Series.__getitem__` and :meth:`DataFrame.__getitem__`, (:issue:`39004`)
132133
- :meth:`Series.apply` can now accept list-like or dictionary-like arguments that aren't lists or dictionaries, e.g. ``ser.apply(np.array(["sum", "mean"]))``, which was already the case for :meth:`DataFrame.apply` (:issue:`39140`)
133134
- :meth:`DataFrame.plot.scatter` can now accept a categorical column as the argument to ``c`` (:issue:`12380`, :issue:`31357`)
134135
- :meth:`.Styler.set_tooltips` allows on hover tooltips to be added to styled HTML dataframes (:issue:`35643`, :issue:`21266`, :issue:`39317`, :issue:`39708`, :issue:`40284`)
135136
- :meth:`.Styler.set_table_styles` amended to optionally allow certain css-string input arguments (:issue:`39564`)
136137
- :meth:`.Styler.apply` now more consistently accepts ndarray function returns, i.e. in all cases for ``axis`` is ``0, 1 or None`` (:issue:`39359`)
137138
- :meth:`.Styler.apply` and :meth:`.Styler.applymap` now raise errors if wrong format CSS is passed on render (:issue:`39660`)
139+
- :meth:`.Styler.format` adds keyword argument ``escape`` for optional HTML escaping (:issue:`40437`)
138140
- Builtin highlighting methods in :class:`Styler` have a more consistent signature and css customisability (:issue:`40242`)
139141
- :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`)
140142
- :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files.
@@ -299,6 +301,24 @@ cast to ``dtype=object`` (:issue:`38709`)
299301
ser
300302
ser2
301303
304+
305+
.. _whatsnew_130.notable_bug_fixes.rolling_var_precision:
306+
307+
Removed artificial truncation in rolling variance and standard deviation
308+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
309+
310+
:meth:`core.window.Rolling.std` and :meth:`core.window.Rolling.var` will no longer
311+
artificially truncate results that are less than ``~1e-8`` and ``~1e-15`` respectively to
312+
zero (:issue:`37051`, :issue:`40448`, :issue:`39872`).
313+
314+
However, floating point artifacts may now exist in the results when rolling over larger values.
315+
316+
.. ipython:: python
317+
318+
s = pd.Series([7, 5, 5, 5])
319+
s.rolling(3).var()
320+
321+
302322
.. _whatsnew_130.api_breaking.deps:
303323

304324
Increased minimum versions for dependencies
@@ -403,7 +423,7 @@ Deprecations
403423
- Using ``.astype`` to convert between ``datetime64[ns]`` dtype and :class:`DatetimeTZDtype` is deprecated and will raise in a future version, use ``obj.tz_localize`` or ``obj.dt.tz_localize`` instead (:issue:`38622`)
404424
- Deprecated casting ``datetime.date`` objects to ``datetime64`` when used as ``fill_value`` in :meth:`DataFrame.unstack`, :meth:`DataFrame.shift`, :meth:`Series.shift`, and :meth:`DataFrame.reindex`, pass ``pd.Timestamp(dateobj)`` instead (:issue:`39767`)
405425
- Deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` in favour of :meth:`.Styler.format` with ``na_rep`` and ``precision`` as existing and new input arguments respectively (:issue:`40134`, :issue:`40425`)
406-
- Deprecated allowing partial failure in :meth:`Series.transform` and :meth:`DataFrame.transform` when ``func`` is list-like or dict-like; will raise if any function fails on a column in a future version (:issue:`40211`)
426+
- 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`)
407427
- 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`)
408428
- Deprecated the use of ``**kwargs`` in :class:`.ExcelWriter`; use the keyword argument ``engine_kwargs`` instead (:issue:`40430`)
409429

@@ -613,6 +633,7 @@ Groupby/resample/rolling
613633
- Bug in :class:`core.window.ewm.ExponentialMovingWindow` when calling ``__getitem__`` would incorrectly raise a ``ValueError`` when providing ``times`` (:issue:`40164`)
614634
- Bug in :class:`core.window.ewm.ExponentialMovingWindow` when calling ``__getitem__`` would not retain ``com``, ``span``, ``alpha`` or ``halflife`` attributes (:issue:`40164`)
615635
- :class:`core.window.ewm.ExponentialMovingWindow` now raises a ``NotImplementedError`` when specifying ``times`` with ``adjust=False`` due to an incorrect calculation (:issue:`40098`)
636+
- Bug in :meth:`Series.asfreq` and :meth:`DataFrame.asfreq` dropping rows when the index is not sorted (:issue:`39805`)
616637

617638
Reshaping
618639
^^^^^^^^^
@@ -631,6 +652,7 @@ Reshaping
631652
- Allow :class:`Index` to be passed to the :func:`numpy.all` function (:issue:`40180`)
632653
- Bug in :meth:`DataFrame.stack` not preserving ``CategoricalDtype`` in a ``MultiIndex`` (:issue:`36991`)
633654
- Bug in :func:`to_datetime` raising error when input sequence contains unhashable items (:issue:`39756`)
655+
- Bug in :meth:`Series.explode` preserving index when ``ignore_index`` was ``True`` and values were scalars (:issue:`40487`)
634656

635657
Sparse
636658
^^^^^^
@@ -662,6 +684,7 @@ Other
662684
- Bug in :class:`Styler` where rendered HTML was missing a column class identifier for certain header cells (:issue:`39716`)
663685
- Bug in :meth:`Styler.background_gradient` where text-color was not determined correctly (:issue:`39888`)
664686
- Bug in :class:`Styler` where multiple elements in CSS-selectors were not correctly added to ``table_styles`` (:issue:`39942`)
687+
- Bug in :class:`.Styler` where copying from Jupyter dropped top left cell and misaligned headers (:issue:`12147`)
665688
- Bug in :meth:`DataFrame.equals`, :meth:`Series.equals`, :meth:`Index.equals` with object-dtype containing ``np.datetime64("NaT")`` or ``np.timedelta64("NaT")`` (:issue:`39650`)
666689
- Bug in :func:`pandas.util.show_versions` where console JSON output was not proper JSON (:issue:`39701`)
667690
- Bug in :meth:`DataFrame.convert_dtypes` incorrectly raised ValueError when called on an empty DataFrame (:issue:`40393`)

pandas/_libs/algos.pxd

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
from pandas._libs.util cimport numeric
22

33

4-
cdef inline Py_ssize_t swap(numeric *a, numeric *b) nogil:
5-
cdef:
6-
numeric t
7-
8-
# cython doesn't allow pointer dereference so use array syntax
9-
t = a[0]
10-
a[0] = b[0]
11-
b[0] = t
12-
return 0
13-
14-
15-
cdef enum TiebreakEnumType:
16-
TIEBREAK_AVERAGE
17-
TIEBREAK_MIN,
18-
TIEBREAK_MAX
19-
TIEBREAK_FIRST
20-
TIEBREAK_FIRST_DESCENDING
21-
TIEBREAK_DENSE
4+
cdef numeric kth_smallest_c(numeric* arr, Py_ssize_t k, Py_ssize_t n) nogil

0 commit comments

Comments
 (0)