Skip to content

Commit fdb5861

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix-merge-suffixes-61402
2 parents 9bc2b66 + 05f032c commit fdb5861

Some content is hidden

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

60 files changed

+685
-402
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
skip: [pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.11.8
22+
rev: v0.11.12
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]
@@ -74,7 +74,7 @@ repos:
7474
hooks:
7575
- id: isort
7676
- repo: https://github.com/asottile/pyupgrade
77-
rev: v3.19.1
77+
rev: v3.20.0
7878
hooks:
7979
- id: pyupgrade
8080
args: [--py310-plus]
@@ -95,14 +95,14 @@ repos:
9595
- id: sphinx-lint
9696
args: ["--enable", "all", "--disable", "line-too-long"]
9797
- repo: https://github.com/pre-commit/mirrors-clang-format
98-
rev: v20.1.3
98+
rev: v20.1.5
9999
hooks:
100100
- id: clang-format
101101
files: ^pandas/_libs/src|^pandas/_libs/include
102102
args: [-i]
103103
types_or: [c, c++]
104104
- repo: https://github.com/trim21/pre-commit-mirror-meson
105-
rev: v1.8.0
105+
rev: v1.8.1
106106
hooks:
107107
- id: meson-fmt
108108
args: ['--inplace']

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
"pip+build": [],
45-
"Cython": ["3.0"],
45+
"Cython": [],
4646
"matplotlib": [],
4747
"sqlalchemy": [],
4848
"scipy": [],

ci/deps/actions-310-minimum_versions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88

99
# build dependencies
1010
- versioneer
11-
- cython>=0.29.33
11+
- cython<4.0.0a0
1212
- meson=1.2.1
1313
- meson-python=0.13.1
1414

ci/deps/actions-310.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer
9-
- cython>=0.29.33
9+
- cython<4.0.0a0
1010
- meson=1.2.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-311-downstream_compat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77

88
# build dependencies
99
- versioneer
10-
- cython>=0.29.33
10+
- cython<4.0.0a0
1111
- meson=1.2.1
1212
- meson-python=0.13.1
1313

ci/deps/actions-311-numpydev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- versioneer
99
- meson=1.2.1
1010
- meson-python=0.13.1
11-
- cython>=0.29.33
11+
- cython<4.0.0a0
1212

1313
# test dependencies
1414
- pytest>=7.3.2

ci/deps/actions-311-pyarrownightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
# build dependencies
88
- versioneer
99
- meson=1.2.1
10-
- cython>=0.29.33
10+
- cython<4.0.0a0
1111
- meson-python=0.13.1
1212

1313
# test dependencies

ci/deps/actions-311.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer
9-
- cython>=0.29.33
9+
- cython<4.0.0a0
1010
- meson=1.2.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-312.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer
9-
- cython>=0.29.33
9+
- cython<4.0.0a0
1010
- meson=1.2.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-313-freethreading.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies:
77
# build dependencies
88
- setuptools
99
- versioneer
10+
- cython<4.0.0a0
1011
- meson=1.8.0
1112
- meson-python=0.18.0
1213

@@ -21,10 +22,8 @@ dependencies:
2122
# optional dependencies
2223
- hypothesis>=6.84.0
2324

24-
# Move Cython to build dependencies, once they release a version that supports freethreading
2525
- pip:
2626
# No free-threaded coveragepy (with the C-extension) on conda-forge yet
2727
- pytest-cov
2828
- "tzdata>=2022.7"
2929
- "--extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"
30-
- "cython"

ci/deps/actions-313.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer
9-
- cython>=0.29.33
9+
- cython<4.0.0a0
1010
- meson=1.2.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-pypy-39.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99

1010
# build dependencies
1111
- versioneer
12-
- cython>=0.29.33
12+
- cython<4.0.0a0
1313
- meson=1.2.1
1414
- meson-python=0.13.1
1515

doc/cheatsheet/Pandas_Cheat_Sheet.pdf

28.6 KB
Binary file not shown.
-1 Bytes
Binary file not shown.

doc/source/development/contributing_environment.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ This option allows you to configure where meson stores your built C extensions,
251251
Sometimes, it might be useful to compile pandas with debugging symbols, when debugging C extensions.
252252
Appending ``-Csetup-args="-Ddebug=true"`` will do the trick.
253253

254-
With pip, it is possible to chain together multiple config settings (for example specifying both a build directory
254+
With pip, it is possible to chain together multiple config settings. For example, specifying both a build directory
255255
and building with debug symbols would look like
256256
``-Cbuilddir="your builddir here" -Csetup-args="-Dbuildtype=debug"``.
257257

doc/source/user_guide/indexing.rst

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ The ``.loc`` attribute is the primary access method. The following are valid inp
325325

326326
* A single label, e.g. ``5`` or ``'a'`` (Note that ``5`` is interpreted as a *label* of the index. This use is **not** an integer position along the index.).
327327
* A list or array of labels ``['a', 'b', 'c']``.
328-
* A slice object with labels ``'a':'f'`` (Note that contrary to usual Python
328+
* A slice object with labels ``'a':'f'``. Note that contrary to usual Python
329329
slices, **both** the start and the stop are included, when present in the
330330
index! See :ref:`Slicing with labels <indexing.slicing_with_labels>`.
331331
* A boolean array.
@@ -1461,16 +1461,33 @@ Looking up values by index/column labels
14611461

14621462
Sometimes you want to extract a set of values given a sequence of row labels
14631463
and column labels, this can be achieved by ``pandas.factorize`` and NumPy indexing.
1464-
For instance:
14651464

1466-
.. ipython:: python
1465+
For heterogeneous column types, we subset columns to avoid unnecessary NumPy conversions:
1466+
1467+
.. code-block:: python
1468+
1469+
def pd_lookup_het(df, row_labels, col_labels):
1470+
rows = df.index.get_indexer(row_labels)
1471+
cols = df.columns.get_indexer(col_labels)
1472+
sub = df.take(np.unique(cols), axis=1)
1473+
sub = sub.take(np.unique(rows), axis=0)
1474+
rows = sub.index.get_indexer(row_labels)
1475+
values = sub.melt()["value"]
1476+
cols = sub.columns.get_indexer(col_labels)
1477+
flat_index = rows + cols * len(sub)
1478+
result = values[flat_index]
1479+
return result
1480+
1481+
For homogeneous column types, it is fastest to skip column subsetting and go directly to NumPy:
1482+
1483+
.. code-block:: python
14671484
1468-
df = pd.DataFrame({'col': ["A", "A", "B", "B"],
1469-
'A': [80, 23, np.nan, 22],
1470-
'B': [80, 55, 76, 67]})
1471-
df
1472-
idx, cols = pd.factorize(df['col'])
1473-
df.reindex(cols, axis=1).to_numpy()[np.arange(len(df)), idx]
1485+
def pd_lookup_hom(df, row_labels, col_labels):
1486+
rows = df.index.get_indexer(row_labels)
1487+
df = df.loc[:, sorted(set(col_labels))]
1488+
cols = df.columns.get_indexer(col_labels)
1489+
result = df.to_numpy()[rows, cols]
1490+
return result
14741491
14751492
Formerly this could be achieved with the dedicated ``DataFrame.lookup`` method
14761493
which was deprecated in version 1.2.0 and removed in version 2.0.0.

doc/source/user_guide/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ of multi-columns indices.
14151415
14161416
.. note::
14171417
If an ``index_col`` is not specified (e.g. you don't have an index, or wrote it
1418-
with ``df.to_csv(..., index=False)``, then any ``names`` on the columns index will
1418+
with ``df.to_csv(..., index=False)``), then any ``names`` on the columns index will
14191419
be *lost*.
14201420

14211421
.. ipython:: python

doc/source/user_guide/sparse.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ and in the Python interpreter.
4040

4141
.. ipython:: python
4242
43-
'dense : {:0.2f} bytes'.format(df.memory_usage().sum() / 1e3)
44-
'sparse: {:0.2f} bytes'.format(sdf.memory_usage().sum() / 1e3)
43+
f'dense: {df.memory_usage().sum()} bytes'
44+
f'sparse: {sdf.memory_usage().sum()} bytes'
4545
4646
Functionally, their behavior should be nearly
4747
identical to their dense counterparts.

doc/source/user_guide/timeseries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ you can use the ``tz_convert`` method.
24582458

24592459
For ``pytz`` time zones, it is incorrect to pass a time zone object directly into
24602460
the ``datetime.datetime`` constructor
2461-
(e.g., ``datetime.datetime(2011, 1, 1, tzinfo=pytz.timezone('US/Eastern'))``.
2461+
(e.g., ``datetime.datetime(2011, 1, 1, tzinfo=pytz.timezone('US/Eastern'))``).
24622462
Instead, the datetime needs to be localized using the ``localize`` method
24632463
on the ``pytz`` time zone object.
24642464

0 commit comments

Comments
 (0)