Skip to content

Commit 8ebb3e1

Browse files
authored
Merge branch 'pandas-dev:main' into 59078-nrow-doc
2 parents c03c1d1 + 32ceb4a commit 8ebb3e1

File tree

53 files changed

+365
-419
lines changed

Some content is hidden

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

53 files changed

+365
-419
lines changed

.github/actions/build_pandas/action.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ inputs:
44
editable:
55
description: Whether to build pandas in editable mode (default true)
66
default: true
7-
meson_args:
8-
description: Extra flags to pass to meson
9-
required: false
10-
cflags_adds:
11-
description: Items to append to the CFLAGS variable
12-
required: false
137
runs:
148
using: composite
159
steps:
@@ -30,12 +24,11 @@ runs:
3024

3125
- name: Build Pandas
3226
run: |
33-
export CFLAGS="$CFLAGS ${{ inputs.cflags_adds }}"
3427
if [[ ${{ inputs.editable }} == "true" ]]; then
35-
pip install -e . --no-build-isolation -v --no-deps ${{ inputs.meson_args }} \
28+
pip install -e . --no-build-isolation -v --no-deps \
3629
--config-settings=setup-args="--werror"
3730
else
38-
pip install . --no-build-isolation -v --no-deps ${{ inputs.meson_args }} \
31+
pip install . --no-build-isolation -v --no-deps \
3932
--config-settings=setup-args="--werror"
4033
fi
4134
shell: bash -el {0}

.github/actions/run-tests/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ runs:
77
shell: bash -el {0}
88

99
- name: Publish test results
10-
uses: actions/upload-artifact@v3
10+
uses: actions/upload-artifact@v4
1111
with:
1212
name: Test results
1313
path: test-data.xml
1414
if: failure()
1515

1616
- name: Upload coverage to Codecov
17-
uses: codecov/codecov-action@v3
17+
uses: codecov/codecov-action@v4
1818
with:
1919
flags: unittests
2020
name: codecov-pandas

.github/workflows/unit-tests.yml

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ jobs:
7474
PATTERN: ${{ matrix.pattern }}
7575
LANG: ${{ matrix.lang || 'C.UTF-8' }}
7676
LC_ALL: ${{ matrix.lc_all || '' }}
77-
PANDAS_CI: ${{ matrix.pandas_ci || '1' }}
77+
PANDAS_CI: '1'
7878
TEST_ARGS: ${{ matrix.test_args || '' }}
79-
PYTEST_WORKERS: ${{ matrix.pytest_workers || 'auto' }}
79+
PYTEST_WORKERS: 'auto'
8080
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }}
8181
NPY_PROMOTION_STATE: ${{ matrix.env_file == 'actions-311-numpydev.yaml' && 'weak' || 'legacy' }}
8282
# Clipboard tests
@@ -88,7 +88,7 @@ jobs:
8888

8989
services:
9090
mysql:
91-
image: mysql:8.0.33
91+
image: mysql:8
9292
env:
9393
MYSQL_ALLOW_EMPTY_PASSWORD: yes
9494
MYSQL_DATABASE: pandas
@@ -101,7 +101,7 @@ jobs:
101101
- 3306:3306
102102

103103
postgres:
104-
image: postgres:13
104+
image: postgres:16
105105
env:
106106
PGUSER: postgres
107107
POSTGRES_USER: postgres
@@ -116,7 +116,7 @@ jobs:
116116
- 5432:5432
117117

118118
moto:
119-
image: motoserver/moto:4.1.13
119+
image: motoserver/moto:5.0.0
120120
env:
121121
AWS_ACCESS_KEY_ID: foobar_key
122122
AWS_SECRET_ACCESS_KEY: foobar_secret
@@ -148,9 +148,6 @@ jobs:
148148
uses: ./.github/actions/build_pandas
149149
# TODO: Re-enable once Pypy has Pypy 3.10 on conda-forge
150150
if: ${{ matrix.name != 'Pypy' }}
151-
with:
152-
meson_args: ${{ matrix.meson_args }}
153-
cflags_adds: ${{ matrix.cflags_adds }}
154151

155152
- name: Test (not single_cpu)
156153
uses: ./.github/actions/run-tests
@@ -302,7 +299,7 @@ jobs:
302299
# To freeze this file, uncomment out the ``if: false`` condition, and migrate the jobs
303300
# to the corresponding posix/windows-macos/sdist etc. workflows.
304301
# Feel free to modify this comment as necessary.
305-
if: false # Uncomment this to freeze the workflow, comment it to unfreeze
302+
# if: false # Uncomment this to freeze the workflow, comment it to unfreeze
306303
defaults:
307304
run:
308305
shell: bash -eou pipefail {0}
@@ -317,7 +314,7 @@ jobs:
317314

318315
concurrency:
319316
# https://github.community/t/concurrecy-not-work-for-push/183068/7
320-
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.os }}-${{ matrix.pytest_target }}-dev
317+
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.os }}-python-dev
321318
cancel-in-progress: true
322319

323320
env:
@@ -334,7 +331,7 @@ jobs:
334331
- name: Set up Python Dev Version
335332
uses: actions/setup-python@v5
336333
with:
337-
python-version: '3.12-dev'
334+
python-version: '3.13-dev'
338335

339336
- name: Build Environment
340337
run: |
@@ -349,6 +346,51 @@ jobs:
349346
- name: Run Tests
350347
uses: ./.github/actions/run-tests
351348

349+
python-freethreading:
350+
defaults:
351+
run:
352+
shell: bash -eou pipefail {0}
353+
runs-on: ubuntu-22.04
354+
355+
timeout-minutes: 90
356+
357+
concurrency:
358+
# https://github.community/t/concurrecy-not-work-for-push/183068/7
359+
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.os }}-python-freethreading-dev
360+
cancel-in-progress: true
361+
362+
env:
363+
PYTEST_WORKERS: "auto"
364+
PANDAS_CI: 1
365+
PATTERN: "not slow and not network and not clipboard and not single_cpu"
366+
PYTEST_TARGET: pandas
367+
368+
steps:
369+
- uses: actions/checkout@v4
370+
with:
371+
fetch-depth: 0
372+
373+
- name: Set up Python Free-threading Version
374+
uses: deadsnakes/[email protected]
375+
with:
376+
python-version: 3.13-dev
377+
nogil: true
378+
379+
- name: Build Environment
380+
run: |
381+
python --version
382+
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.2.1 meson-python==0.13.1
383+
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy cython
384+
python -m pip install versioneer[toml]
385+
python -m pip install python-dateutil pytz tzdata hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov
386+
python -m pip install -ve . --no-build-isolation --no-index --no-deps --config-settings=setup-args="--werror"
387+
python -m pip list
388+
389+
- name: Run Tests
390+
uses: ./.github/actions/run-tests
391+
env:
392+
PYTHON_GIL: 0
393+
352394
emscripten:
353395
# Note: the Python version, Emscripten toolchain version are determined
354396
# by the Pyodide version. The appropriate versions can be found in the

asv_bench/benchmarks/tslibs/timedelta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def time_from_int(self):
2020
Timedelta(123456789)
2121

2222
def time_from_unit(self):
23-
Timedelta(1, unit="d")
23+
Timedelta(1, unit="D")
2424

2525
def time_from_components(self):
2626
Timedelta(

ci/code_checks.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
162162
-i "pandas.Series.ne SA01" \
163163
-i "pandas.Series.pad PR01,SA01" \
164164
-i "pandas.Series.plot PR02" \
165-
-i "pandas.Series.pop RT03,SA01" \
165+
-i "pandas.Series.pop SA01" \
166166
-i "pandas.Series.prod RT03" \
167167
-i "pandas.Series.product RT03" \
168168
-i "pandas.Series.reorder_levels RT03,SA01" \
@@ -260,7 +260,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
260260
-i "pandas.Timestamp.to_period PR01,SA01" \
261261
-i "pandas.Timestamp.today SA01" \
262262
-i "pandas.Timestamp.toordinal SA01" \
263-
-i "pandas.Timestamp.tz SA01" \
264263
-i "pandas.Timestamp.tz_localize SA01" \
265264
-i "pandas.Timestamp.tzinfo GL08" \
266265
-i "pandas.Timestamp.tzname SA01" \

ci/deps/actions-311-pyarrownightly.yaml

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

1919
# required dependencies
2020
- python-dateutil
21-
- numpy
21+
- numpy<2
2222
- pytz
2323
- pip
2424

doc/source/whatsnew/v3.0.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Other enhancements
3939
- Users can globally disable any ``PerformanceWarning`` by setting the option ``mode.performance_warnings`` to ``False`` (:issue:`56920`)
4040
- :meth:`Styler.format_index_names` can now be used to format the index and column names (:issue:`48936` and :issue:`47489`)
4141
- :class:`.errors.DtypeWarning` improved to include column names when mixed data types are detected (:issue:`58174`)
42+
- :func:`DataFrame.to_excel` argument ``merge_cells`` now accepts a value of ``"columns"`` to only merge :class:`MultiIndex` column header header cells (:issue:`35384`)
4243
- :meth:`DataFrame.corrwith` now accepts ``min_periods`` as optional arguments, as in :meth:`DataFrame.corr` and :meth:`Series.corr` (:issue:`9490`)
4344
- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
4445
- :meth:`DataFrame.fillna` and :meth:`Series.fillna` can now accept ``value=None``; for non-object dtype the corresponding NA value will be used (:issue:`57723`)
@@ -380,6 +381,8 @@ Other Removals
380381
- Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting frequencies in :class:`Minute`, :class:`Milli`, :class:`Micro`, :class:`Nano` (:issue:`57627`)
381382
- Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`57627`)
382383
- Enforced deprecation of the behavior of :func:`concat` when ``len(keys) != len(objs)`` would truncate to the shorter of the two. Now this raises a ``ValueError`` (:issue:`43485`)
384+
- Enforced deprecation of the behavior of :meth:`DataFrame.replace` and :meth:`Series.replace` with :class:`CategoricalDtype` that would introduce new categories. (:issue:`58270`)
385+
- Enforced deprecation of the behavior of :meth:`Series.argsort` in the presence of NA values (:issue:`58232`)
383386
- Enforced deprecation of values "pad", "ffill", "bfill", and "backfill" for :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` (:issue:`57869`)
384387
- Enforced deprecation removing :meth:`Categorical.to_list`, use ``obj.tolist()`` instead (:issue:`51254`)
385388
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
@@ -544,6 +547,7 @@ MultiIndex
544547
^^^^^^^^^^
545548
- :func:`DataFrame.loc` with ``axis=0`` and :class:`MultiIndex` when setting a value adds extra columns (:issue:`58116`)
546549
- :meth:`DataFrame.melt` would not accept multiple names in ``var_name`` when the columns were a :class:`MultiIndex` (:issue:`58033`)
550+
- :meth:`MultiIndex.insert` would not insert NA value correctly at unified location of index -1 (:issue:`59003`)
547551
-
548552

549553
I/O
@@ -556,7 +560,9 @@ I/O
556560
- Bug in :meth:`HDFStore.get` was failing to save data of dtype datetime64[s] correctly (:issue:`59004`)
557561
- Bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)
558562
- Bug in :meth:`read_csv` raising ``TypeError`` when ``nrows`` and ``iterator`` are specified without specifying a ``chunksize``. (:issue:`59079`)
563+
- Bug in :meth:`read_excel` raising ``ValueError`` when passing array of boolean values when ``dtype="boolean"``. (:issue:`58159`)
559564
- Bug in :meth:`read_stata` raising ``KeyError`` when input file is stored in big-endian format and contains strL data. (:issue:`58638`)
565+
-
560566

561567
Period
562568
^^^^^^

pandas/_libs/src/vendored/ujson/python/objToJSON.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ static void NpyArr_iterBegin(JSOBJ _obj, JSONTypeContext *tc) {
410410
npyarr->type_num = PyArray_DESCR(obj)->type_num;
411411

412412
if (GET_TC(tc)->transpose) {
413-
npyarr->dim = PyArray_DIM(obj, npyarr->ndim);
414-
npyarr->stride = PyArray_STRIDE(obj, npyarr->ndim);
413+
npyarr->dim = PyArray_DIM(obj, (int)npyarr->ndim);
414+
npyarr->stride = PyArray_STRIDE(obj, (int)npyarr->ndim);
415415
npyarr->stridedim = npyarr->ndim;
416416
npyarr->index[npyarr->ndim] = 0;
417417
npyarr->inc = -1;
@@ -452,8 +452,8 @@ static void NpyArrPassThru_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
452452
return;
453453
}
454454
const PyArrayObject *arrayobj = (const PyArrayObject *)npyarr->array;
455-
npyarr->dim = PyArray_DIM(arrayobj, npyarr->stridedim);
456-
npyarr->stride = PyArray_STRIDE(arrayobj, npyarr->stridedim);
455+
npyarr->dim = PyArray_DIM(arrayobj, (int)npyarr->stridedim);
456+
npyarr->stride = PyArray_STRIDE(arrayobj, (int)npyarr->stridedim);
457457
npyarr->dataptr += npyarr->stride;
458458

459459
NpyArr_freeItemValue(obj, tc);
@@ -524,8 +524,8 @@ static int NpyArr_iterNext(JSOBJ _obj, JSONTypeContext *tc) {
524524
}
525525
const PyArrayObject *arrayobj = (const PyArrayObject *)npyarr->array;
526526

527-
npyarr->dim = PyArray_DIM(arrayobj, npyarr->stridedim);
528-
npyarr->stride = PyArray_STRIDE(arrayobj, npyarr->stridedim);
527+
npyarr->dim = PyArray_DIM(arrayobj, (int)npyarr->stridedim);
528+
npyarr->stride = PyArray_STRIDE(arrayobj, (int)npyarr->stridedim);
529529
npyarr->index[npyarr->stridedim] = 0;
530530

531531
((PyObjectEncoder *)tc->encoder)->npyCtxtPassthru = npyarr;

pandas/_libs/tslibs/offsets.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4948,7 +4948,12 @@ cpdef to_offset(freq, bint is_period=False):
49484948
if result is None:
49494949
raise ValueError(INVALID_FREQ_ERR_MSG.format(freq))
49504950

4951-
if is_period and not hasattr(result, "_period_dtype_code"):
4951+
try:
4952+
has_period_dtype_code = hasattr(result, "_period_dtype_code")
4953+
except ValueError:
4954+
has_period_dtype_code = False
4955+
4956+
if is_period and not has_period_dtype_code:
49524957
if isinstance(freq, str):
49534958
raise ValueError(f"{result.name} is not supported as period frequency")
49544959
else:

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,17 @@ timedelta}, default 'raise'
23682368
"""
23692369
Alias for tzinfo.
23702370
2371+
The `tz` property provides a simple and direct way to retrieve the timezone
2372+
information of a `Timestamp` object. It is particularly useful when working
2373+
with time series data that includes timezone information, allowing for easy
2374+
access and manipulation of the timezone context.
2375+
2376+
See Also
2377+
--------
2378+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
2379+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
2380+
Timestamp.tz_localize : Localize the Timestamp to a timezone.
2381+
23712382
Examples
23722383
--------
23732384
>>> ts = pd.Timestamp(1584226800, unit='s', tz='Europe/Stockholm')

0 commit comments

Comments
 (0)