Skip to content

Commit 741098a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into arrow/docs
2 parents a9e8581 + 5b42542 commit 741098a

File tree

146 files changed

+2058
-579
lines changed

Some content is hidden

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

146 files changed

+2058
-579
lines changed

.github/workflows/32-bit-linux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
/opt/python/cp38-cp38/bin/python -m venv ~/virtualenvs/pandas-dev && \
3939
. ~/virtualenvs/pandas-dev/bin/activate && \
4040
python -m pip install --no-deps -U pip wheel 'setuptools<60.0.0' && \
41-
pip install cython==0.29.30 numpy python-dateutil pytz pytest pytest-xdist pytest-asyncio>=0.17 hypothesis && \
41+
pip install cython numpy python-dateutil pytz pytest pytest-xdist pytest-asyncio>=0.17 hypothesis && \
4242
python setup.py build_ext -q -j2 && \
4343
python -m pip install --no-build-isolation --no-use-pep517 -e . && \
4444
export PANDAS_CI=1 && \

.github/workflows/sdist.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ jobs:
7979
run: |
8080
case "${{matrix.python-version}}" in
8181
3.8)
82-
pip install numpy==1.19.5 ;;
82+
pip install numpy==1.20.3 ;;
8383
3.9)
84-
pip install numpy==1.19.5 ;;
84+
pip install numpy==1.20.3 ;;
8585
3.10)
8686
pip install numpy==1.21.2 ;;
8787
esac

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ repos:
9393
types: [python]
9494
stages: [manual]
9595
additional_dependencies: &pyright_dependencies
96-
96+
9797
- id: pyright_reportGeneralTypeIssues
9898
# note: assumes python env is setup and activated
9999
name: pyright reportGeneralTypeIssues

asv_bench/asv.conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// followed by the pip installed packages).
4343
"matrix": {
4444
"numpy": [],
45-
"Cython": ["0.29.30"],
45+
"Cython": ["0.29.32"],
4646
"matplotlib": [],
4747
"sqlalchemy": [],
4848
"scipy": [],

ci/deps/actions-310-numpydev.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ dependencies:
1616
- pytz
1717
- pip
1818
- pip:
19-
#- cython # TODO: don't install from master after Cython 3.0.0a11 is released
20-
- "git+https://github.com/cython/cython.git@master"
19+
- "cython"
2120
- "--extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple"
2221
- "--pre"
2322
- "numpy"

ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies:
55
- python=3.10
66

77
# test dependencies
8-
- cython=0.29.30
8+
- cython>=0.29.32
99
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.31

ci/deps/actions-38-downstream_compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- python=3.8
77

88
# test dependencies
9-
- cython=0.29.30
9+
- cython>=0.29.32
1010
- pytest>=6.0
1111
- pytest-cov
1212
- pytest-xdist>=1.31

ci/deps/actions-38-minimum_versions.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
- python=3.8.0
88

99
# test dependencies
10-
- cython=0.29.30
10+
- cython>=0.29.32
1111
- pytest>=6.0
1212
- pytest-cov
1313
- pytest-xdist>=1.31
@@ -17,7 +17,7 @@ dependencies:
1717

1818
# required dependencies
1919
- python-dateutil=2.8.1
20-
- numpy=1.19.5
20+
- numpy=1.20.3
2121
- pytz=2020.1
2222

2323
# optional dependencies

ci/deps/actions-38.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies:
55
- python=3.8
66

77
# test dependencies
8-
- cython=0.29.30
8+
- cython>=0.29.32
99
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.31

ci/deps/actions-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies:
55
- python=3.9
66

77
# test dependencies
8-
- cython=0.29.30
8+
- cython>=0.29.32
99
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.31

ci/deps/actions-pypy-38.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- python=3.8[build=*_pypy] # TODO: use this once pypy3.8 is available
99

1010
# tools
11-
- cython>=0.29.30
11+
- cython>=0.29.32
1212
- pytest>=6.0
1313
- pytest-cov
1414
- pytest-asyncio

ci/deps/circle-38-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies:
55
- python=3.8
66

77
# test dependencies
8-
- cython=0.29.30
8+
- cython>=0.29.32
99
- pytest>=6.0
1010
- pytest-cov
1111
- pytest-xdist>=1.31

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Dependencies
235235
================================================================ ==========================
236236
Package Minimum supported version
237237
================================================================ ==========================
238-
`NumPy <https://numpy.org>`__ 1.19.5
238+
`NumPy <https://numpy.org>`__ 1.20.3
239239
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.1
240240
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
241241
================================================================ ==========================

doc/source/reference/style.rst

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Style application
4141
Styler.applymap_index
4242
Styler.format
4343
Styler.format_index
44+
Styler.relabel_index
4445
Styler.hide
4546
Styler.concat
4647
Styler.set_td_classes

doc/source/reference/testing.rst

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Exceptions and warnings
2727
errors.AbstractMethodError
2828
errors.AccessorRegistrationWarning
2929
errors.AttributeConflictWarning
30+
errors.CategoricalConversionWarning
3031
errors.ClosedFileError
3132
errors.CSSWarning
3233
errors.DatabaseError
@@ -36,6 +37,7 @@ Exceptions and warnings
3637
errors.EmptyDataError
3738
errors.IncompatibilityWarning
3839
errors.IndexingError
40+
errors.InvalidColumnName
3941
errors.InvalidIndexError
4042
errors.IntCastingNaNError
4143
errors.MergeError
@@ -49,6 +51,7 @@ Exceptions and warnings
4951
errors.ParserWarning
5052
errors.PerformanceWarning
5153
errors.PossibleDataLossError
54+
errors.PossiblePrecisionLoss
5255
errors.PyperclipException
5356
errors.PyperclipWindowsException
5457
errors.SettingWithCopyError
@@ -57,6 +60,7 @@ Exceptions and warnings
5760
errors.UndefinedVariableError
5861
errors.UnsortedIndexError
5962
errors.UnsupportedFunctionCall
63+
errors.ValueLabelTypeMismatch
6064

6165
Bug report function
6266
-------------------

doc/source/user_guide/10min.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,12 @@ Converting the raw grades to a categorical data type:
680680
df["grade"] = df["raw_grade"].astype("category")
681681
df["grade"]
682682
683-
Rename the categories to more meaningful names (assigning to
684-
:meth:`Series.cat.categories` is in place!):
683+
Rename the categories to more meaningful names:
685684

686685
.. ipython:: python
687686
688-
df["grade"].cat.categories = ["very good", "good", "very bad"]
687+
new_categories = ["very good", "good", "very bad"]
688+
df["grade"] = df["grade"].cat.rename_categories(new_categories)
689689
690690
Reorder the categories and simultaneously add the missing categories (methods under :meth:`Series.cat` return a new :class:`Series` by default):
691691

doc/source/user_guide/categorical.rst

+8-9
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,16 @@ It's also possible to pass in the categories in a specific order:
334334
Renaming categories
335335
~~~~~~~~~~~~~~~~~~~
336336

337-
Renaming categories is done by assigning new values to the
338-
``Series.cat.categories`` property or by using the
337+
Renaming categories is done by using the
339338
:meth:`~pandas.Categorical.rename_categories` method:
340339

341340

342341
.. ipython:: python
343342
344343
s = pd.Series(["a", "b", "c", "a"], dtype="category")
345344
s
346-
s.cat.categories = ["Group %s" % g for g in s.cat.categories]
347-
s
348-
s = s.cat.rename_categories([1, 2, 3])
345+
new_categories = ["Group %s" % g for g in s.cat.categories]
346+
s = s.cat.rename_categories(new_categories)
349347
s
350348
# You can also pass a dict-like object to map the renaming
351349
s = s.cat.rename_categories({1: "x", 2: "y", 3: "z"})
@@ -365,7 +363,7 @@ Categories must be unique or a ``ValueError`` is raised:
365363
.. ipython:: python
366364
367365
try:
368-
s.cat.categories = [1, 1, 1]
366+
s = s.cat.rename_categories([1, 1, 1])
369367
except ValueError as e:
370368
print("ValueError:", str(e))
371369
@@ -374,7 +372,7 @@ Categories must also not be ``NaN`` or a ``ValueError`` is raised:
374372
.. ipython:: python
375373
376374
try:
377-
s.cat.categories = [1, 2, np.nan]
375+
s = s.cat.rename_categories([1, 2, np.nan])
378376
except ValueError as e:
379377
print("ValueError:", str(e))
380378
@@ -702,7 +700,7 @@ of length "1".
702700
.. ipython:: python
703701
704702
df.iat[0, 0]
705-
df["cats"].cat.categories = ["x", "y", "z"]
703+
df["cats"] = df["cats"].cat.rename_categories(["x", "y", "z"])
706704
df.at["h", "cats"] # returns a string
707705
708706
.. note::
@@ -960,7 +958,7 @@ relevant columns back to ``category`` and assign the right categories and catego
960958
961959
s = pd.Series(pd.Categorical(["a", "b", "b", "a", "a", "d"]))
962960
# rename the categories
963-
s.cat.categories = ["very good", "good", "bad"]
961+
s = s.cat.rename_categories(["very good", "good", "bad"])
964962
# reorder the categories and add missing categories
965963
s = s.cat.set_categories(["very bad", "bad", "medium", "good", "very good"])
966964
df = pd.DataFrame({"cats": s, "vals": [1, 2, 3, 4, 5, 6]})
@@ -1164,6 +1162,7 @@ Constructing a ``Series`` from a ``Categorical`` will not copy the input
11641162
change the original ``Categorical``:
11651163

11661164
.. ipython:: python
1165+
:okwarning:
11671166
11681167
cat = pd.Categorical([1, 2, 3, 10], categories=[1, 2, 3, 4, 10])
11691168
s = pd.Series(cat, name="cat")

doc/source/user_guide/groupby.rst

-11
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,6 @@ Index level names may be supplied as keys.
345345
346346
More on the ``sum`` function and aggregation later.
347347

348-
When using ``.groupby()`` on a DatFrame with a MultiIndex, do not specify both ``by`` and ``level``.
349-
The argument validation should be done in ``.groupby()``, using the name of the specific index.
350-
351-
.. ipython:: python
352-
353-
df = pd.DataFrame({"col1": ["a", "b", "c"]})
354-
df.index = pd.MultiIndex.from_arrays([["a", "a", "b"],
355-
[1, 2, 1]],
356-
names=["x", "y"])
357-
df.groupby(["col1", "x"])
358-
359348
Grouping DataFrame with Index levels and columns
360349
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361350
A DataFrame may be grouped by a combination of columns and index levels by

doc/source/user_guide/io.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ This matches the behavior of :meth:`Categorical.set_categories`.
558558
df = pd.read_csv(StringIO(data), dtype="category")
559559
df.dtypes
560560
df["col3"]
561-
df["col3"].cat.categories = pd.to_numeric(df["col3"].cat.categories)
561+
new_categories = pd.to_numeric(df["col3"].cat.categories)
562+
df["col3"] = df["col3"].cat.rename_categories(new_categories)
562563
df["col3"]
563564
564565
@@ -3054,15 +3055,15 @@ Read in the content of the "books.xml" as instance of ``StringIO`` or
30543055
df = pd.read_xml(bio)
30553056
df
30563057
3057-
Even read XML from AWS S3 buckets such as Python Software Foundation's IRS 990 Form:
3058+
Even read XML from AWS S3 buckets such as NIH NCBI PMC Article Datasets providing
3059+
Biomedical and Life Science Jorurnals:
30583060

30593061
.. ipython:: python
30603062
:okwarning:
30613063
30623064
df = pd.read_xml(
3063-
"s3://irs-form-990/201923199349319487_public.xml",
3064-
xpath=".//irs:Form990PartVIISectionAGrp",
3065-
namespaces={"irs": "http://www.irs.gov/efile"}
3065+
"s3://pmc-oa-opendata/oa_comm/xml/all/PMC1236943.xml",
3066+
xpath=".//journal-meta",
30663067
)
30673068
df
30683069

doc/source/user_guide/visualization.rst

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
Chart visualization
77
*******************
88

9+
10+
.. note::
11+
12+
The examples below assume that you're using `Jupyter <https://jupyter.org/>`_.
13+
914
This section demonstrates visualization through charting. For information on
1015
visualization of tabular data please see the section on `Table Visualization <style.ipynb>`_.
1116

doc/source/whatsnew/v0.19.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ Individual columns can be parsed as a ``Categorical`` using a dict specification
271271
such as :func:`to_datetime`.
272272

273273
.. ipython:: python
274+
:okwarning:
274275
275276
df = pd.read_csv(StringIO(data), dtype="category")
276277
df.dtypes

doc/source/whatsnew/v1.4.4.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ including other versions of pandas.
1414

1515
Fixed regressions
1616
~~~~~~~~~~~~~~~~~
17+
- Fixed regression in taking NULL :class:`objects` from a :class:`DataFrame` causing a segmentation violation. These NULL values are created by :meth:`numpy.empty_like` (:issue:`46848`)
1718
- Fixed regression in :func:`concat` materializing :class:`Index` during sorting even if :class:`Index` was already sorted (:issue:`47501`)
19+
- Fixed regression in :meth:`DataFrame.loc` not updating the cache correctly after values were set (:issue:`47867`)
20+
- Fixed regression in :meth:`DataFrame.loc` not aligning index in some cases when setting a :class:`DataFrame` (:issue:`47578`)
1821
- Fixed regression in setting ``None`` or non-string value into a ``string``-dtype Series using a mask (:issue:`47628`)
1922
-
2023

@@ -26,14 +29,15 @@ Bug fixes
2629
~~~~~~~~~
2730
- The :class:`errors.FutureWarning` raised when passing arguments (other than ``filepath_or_buffer``) as positional in :func:`read_csv` is now raised at the correct stacklevel (:issue:`47385`)
2831
- Bug in :meth:`DataFrame.to_sql` when ``method`` was a ``callable`` that did not return an ``int`` and would raise a ``TypeError`` (:issue:`46891`)
32+
- Bug in :meth:`loc.__getitem__` with a list of keys causing an internal inconsistency that could lead to a disconnect between ``frame.at[x, y]`` vs ``frame[y].loc[x]`` (:issue:`22372`)
2933

3034
.. ---------------------------------------------------------------------------
3135
3236
.. _whatsnew_144.other:
3337

3438
Other
3539
~~~~~
36-
-
40+
- The minimum version of Cython needed to compile pandas is now ``0.29.32`` (:issue:`47978`)
3741
-
3842

3943
.. ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)