Skip to content

Commit e55423d

Browse files
authored
Merge branch 'main' into today_now_error
2 parents 38e8eb2 + 1ab02e4 commit e55423d

File tree

185 files changed

+2431
-680
lines changed

Some content is hidden

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

185 files changed

+2431
-680
lines changed

asv_bench/asv.conf.json

Lines changed: 1 addition & 1 deletion
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.yaml

Lines changed: 2 additions & 1 deletion
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
@@ -47,6 +47,7 @@ dependencies:
4747
- scipy
4848
- sqlalchemy
4949
- tabulate
50+
- tzdata>=2022a
5051
- xarray
5152
- xlrd
5253
- xlsxwriter

ci/deps/actions-38-downstream_compat.yaml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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
@@ -49,6 +49,7 @@ dependencies:
4949
- scipy=1.7.1
5050
- sqlalchemy=1.4.16
5151
- tabulate=0.8.9
52+
- tzdata=2022a
5253
- xarray=0.19.0
5354
- xlrd=2.0.1
5455
- xlsxwriter=1.4.3

ci/deps/actions-38.yaml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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
@@ -47,6 +47,7 @@ dependencies:
4747
- scipy
4848
- sqlalchemy
4949
- tabulate
50+
- tzdata>=2022a
5051
- xarray
5152
- xlrd
5253
- xlsxwriter

ci/deps/actions-pypy-38.yaml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,23 @@ For example, :func:`pandas.read_hdf` requires the ``pytables`` package, while
270270
optional dependency is not installed, pandas will raise an ``ImportError`` when
271271
the method requiring that dependency is called.
272272

273+
Timezones
274+
^^^^^^^^^
275+
276+
========================= ========================= =============================================================
277+
Dependency Minimum Version Notes
278+
========================= ========================= =============================================================
279+
tzdata 2022.1(pypi)/ Allows the use of ``zoneinfo`` timezones with pandas.
280+
2022a(for system tzdata) **Note**: You only need to install the pypi package if your
281+
system does not already provide the IANA tz database.
282+
However, the minimum tzdata version still applies, even if it
283+
is not enforced through an error.
284+
285+
If you would like to keep your system tzdata version updated,
286+
it is recommended to use the ``tzdata`` package from
287+
conda-forge.
288+
========================= ========================= =============================================================
289+
273290
Visualization
274291
^^^^^^^^^^^^^
275292

doc/source/reference/style.rst

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 8 additions & 9 deletions
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

Lines changed: 0 additions & 11 deletions
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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 2 deletions
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,15 +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`)
29-
- Bug in :func:`read_xml` when reading XML files with Chinese character tags and would raise ``XMLSyntaxError`` (:issue:`47902`)
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`)
3033

3134
.. ---------------------------------------------------------------------------
3235
3336
.. _whatsnew_144.other:
3437

3538
Other
3639
~~~~~
37-
-
40+
- The minimum version of Cython needed to compile pandas is now ``0.29.32`` (:issue:`47978`)
3841
-
3942

4043
.. ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)