Skip to content

Commit 2d042ff

Browse files
authored
Merge branch 'pandas-dev:main' into main
2 parents 67c9fe3 + 7242759 commit 2d042ff

File tree

22 files changed

+973
-81
lines changed

22 files changed

+973
-81
lines changed

.github/workflows/wheels.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
4646
runs-on: ubuntu-24.04
4747
env:
48+
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
4849
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
4950
outputs:
5051
sdist_file: ${{ steps.save-path.outputs.sdist_name }}
@@ -117,6 +118,7 @@ jobs:
117118
python: ["cp313t", "3.13"]
118119

119120
env:
121+
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
120122
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
121123
steps:
122124
- name: Checkout pandas
@@ -164,7 +166,6 @@ jobs:
164166
uses: pypa/[email protected]
165167
with:
166168
package-dir: ./dist/${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
167-
output-dir: ./dist
168169
env:
169170
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
170171
CIBW_BUILD_FRONTEND: ${{ matrix.cibw_build_frontend || 'pip' }}
@@ -195,19 +196,26 @@ jobs:
195196

196197
- name: Validate wheel RECORD
197198
shell: bash -el {0}
198-
run: for whl in $(ls ./dist/*.whl); do wheel unpack $whl -d /tmp; done
199+
run: for whl in $(ls wheelhouse); do wheel unpack wheelhouse/$whl -d /tmp; done
199200

200201
- uses: actions/upload-artifact@v6
201202
with:
202203
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
203-
path: ./dist/*.whl
204+
path: ./wheelhouse/*.whl
204205

205206
- name: Upload wheels & sdist
206-
if: ${{ success() && env.IS_SCHEDULE_DISPATCH == 'true' }}
207-
uses: scientific-python/[email protected]
208-
with:
209-
artifacts_path: ./dist
210-
anaconda_nightly_upload_token: ${{secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN}}
207+
if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }}
208+
shell: bash -el {0}
209+
env:
210+
PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }}
211+
# trigger an upload to
212+
# https://anaconda.org/scientific-python-nightly-wheels/pandas
213+
# for cron jobs or "Run workflow" (restricted to main branch).
214+
# The tokens were originally generated at anaconda.org
215+
run: |
216+
source ci/upload_wheels.sh
217+
set_upload_vars
218+
upload_wheels
211219
212220
publish:
213221
if: >

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pandas/py.typed
6767
.ropeproject
6868
# wheel files
6969
*.whl
70+
**/wheelhouse/*
7071
pip-wheel-metadata
7172
# coverage
7273
.coverage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ details, see the commit logs at https://github.com/pandas-dev/pandas.
115115
## Dependencies
116116
- [NumPy - Adds support for large, multi-dimensional arrays, matrices and high-level mathematical functions to operate on these arrays](https://www.numpy.org)
117117
- [python-dateutil - Provides powerful extensions to the standard datetime module](https://dateutil.readthedocs.io/en/stable/index.html)
118-
- [tzdata - Provides an IANA time zone database](https://tzdata.readthedocs.io/en/latest/)
118+
- [tzdata - Provides an IANA time zone database](https://tzdata.readthedocs.io/en/latest/) (Only required on Windows/Emscripten)
119119

120120
See the [full installation instructions](https://pandas.pydata.org/pandas-docs/stable/install.html#dependencies) for minimum supported versions of required, recommended and optional dependencies.
121121

ci/upload_wheels.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Modified from numpy's https://github.com/numpy/numpy/blob/main/tools/wheels/upload_wheels.sh
3+
4+
set_upload_vars() {
5+
echo "IS_SCHEDULE_DISPATCH is $IS_SCHEDULE_DISPATCH"
6+
if [[ "$IS_SCHEDULE_DISPATCH" == "true" ]]; then
7+
echo scheduled or dispatched event
8+
export ANACONDA_ORG="scientific-python-nightly-wheels"
9+
export TOKEN="$PANDAS_NIGHTLY_UPLOAD_TOKEN"
10+
export ANACONDA_UPLOAD="true"
11+
else
12+
echo non-dispatch event
13+
export ANACONDA_UPLOAD="false"
14+
fi
15+
}
16+
upload_wheels() {
17+
echo "${PWD}"
18+
if [[ ${ANACONDA_UPLOAD} == true ]]; then
19+
if [ -z "${TOKEN}" ]; then
20+
echo no token set, not uploading
21+
else
22+
# sdists are located under dist folder when built through setup.py
23+
if compgen -G "./dist/*.gz"; then
24+
echo "Found sdist"
25+
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./dist/*.gz
26+
echo "Uploaded sdist"
27+
fi
28+
if compgen -G "./wheelhouse/*.whl"; then
29+
echo "Found wheel"
30+
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./wheelhouse/*.whl
31+
echo "Uploaded wheel"
32+
fi
33+
echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"
34+
fi
35+
fi
36+
}

doc/source/getting_started/install.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ Package Minimum support
150150
================================================================ ==========================
151151
`NumPy <https://numpy.org>`__ 1.26.0
152152
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
153-
`tzdata <https://pypi.org/project/tzdata/>`__ 2023.3
153+
`tzdata <https://pypi.org/project/tzdata/>`__ \* /
154154
================================================================ ==========================
155155

156+
\* ``tzdata`` is only required on Windows and Pyodide (Emscripten).
157+
156158
Generally, the minimum supported version is ~2 years old from the release date of a major or minor pandas version.
157159

158160
.. _install.optional_dependencies:

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,6 @@ The following required dependencies were updated:
686686
+=================+======================+
687687
| numpy | 1.26.0 |
688688
+-----------------+----------------------+
689-
| tzdata | 2023.3 |
690-
+-----------------+----------------------+
691689

692690
For `optional libraries <https://pandas.pydata.org/docs/getting_started/install.html>`_ the general recommendation is to use the latest version.
693691
The following table lists the lowest version per library that is currently being tested throughout the development of pandas.
@@ -1229,6 +1227,7 @@ Indexing
12291227
- Bug in :meth:`DataFrame.loc.__getitem__` and :meth:`DataFrame.iloc.__getitem__` with a :class:`CategoricalDtype` column with integer categories raising when trying to index a row containing a ``NaN`` entry (:issue:`58954`)
12301228
- Bug in :meth:`Index.__getitem__` incorrectly raising with a 0-dim ``np.ndarray`` key (:issue:`55601`)
12311229
- Bug in :meth:`Index.get_indexer` not casting missing values correctly for new string datatype (:issue:`55833`)
1230+
- Bug in :meth:`Index.intersection`, :meth:`Index.union`, :meth:`MultiIndex.intersection`, and :meth:`MultiIndex.union` returning a reference to the original Index instead of a new instance when operating on identical indexes, which could cause metadata corruption when modifying the result (:issue:`63169`)
12321231
- Bug in adding new rows with :meth:`DataFrame.loc.__setitem__` or :class:`Series.loc.__setitem__` which failed to retain dtype on the object's index in some cases (:issue:`41626`)
12331232
- Bug in indexing on a :class:`DatetimeIndex` with a ``timestamp[pyarrow]`` dtype or on a :class:`TimedeltaIndex` with a ``duration[pyarrow]`` dtype (:issue:`62277`)
12341233

pandas/_libs/tslibs/timezones.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ cdef bint is_utc_zoneinfo(tzinfo tz):
5959
utc_zoneinfo = zoneinfo.ZoneInfo("UTC")
6060
except zoneinfo.ZoneInfoNotFoundError:
6161
return False
62-
# Warn if tzdata is too old, even if there is a system tzdata to alert
63-
# users about the mismatch between local/system tzdata
64-
import_optional_dependency("tzdata", errors="warn", min_version="2022.7")
6562

6663
return tz is utc_zoneinfo
6764

pandas/core/arrays/_mixins.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def _hash_pandas_object(
208208
values, encoding=encoding, hash_key=hash_key, categorize=categorize
209209
)
210210

211+
def _cast_pointwise_result(self, values: ArrayLike) -> ArrayLike:
212+
values = np.asarray(values, dtype=object)
213+
return lib.maybe_convert_objects(values, convert_non_numeric=True)
214+
211215
# Signature of "argmin" incompatible with supertype "ExtensionArray"
212216
def argmin(self, axis: AxisInt = 0, skipna: bool = True): # type: ignore[override]
213217
# override base class by adding axis keyword

pandas/core/arrays/arrow/array.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
442442
# e.g. test_by_column_values_with_same_starting_value with nested
443443
# values, one entry of which is an ArrowStringArray
444444
# or test_agg_lambda_complex128_dtype_conversion for complex values
445-
return super()._cast_pointwise_result(values)
445+
values = np.asarray(values, dtype=object)
446+
return lib.maybe_convert_objects(values, convert_non_numeric=True)
446447

447448
if pa.types.is_null(arr.type):
448449
if lib.infer_dtype(values) == "decimal":
@@ -498,7 +499,8 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
498499
if self.dtype.na_value is np.nan:
499500
# ArrowEA has different semantics, so we return numpy-based
500501
# result instead
501-
return super()._cast_pointwise_result(values)
502+
values = np.asarray(values, dtype=object)
503+
return lib.maybe_convert_objects(values, convert_non_numeric=True)
502504
return ArrowExtensionArray(arr)
503505
return self._from_pyarrow_array(arr)
504506

pandas/core/arrays/base.py

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
cast,
2020
overload,
2121
)
22+
import warnings
2223

2324
import numpy as np
2425

@@ -33,6 +34,7 @@
3334
cache_readonly,
3435
set_module,
3536
)
37+
from pandas.util._exceptions import find_stack_level
3638
from pandas.util._validators import (
3739
validate_bool_kwarg,
3840
validate_insert_loc,
@@ -86,6 +88,7 @@
8688
AstypeArg,
8789
AxisInt,
8890
Dtype,
91+
DtypeObj,
8992
FillnaOptions,
9093
InterpolateOptions,
9194
NumpySorter,
@@ -383,13 +386,67 @@ def _from_factorized(cls, values, original):
383386
"""
384387
raise AbstractMethodError(cls)
385388

389+
@classmethod
390+
def _from_scalars(cls, scalars, *, dtype: DtypeObj) -> Self:
391+
"""
392+
Strict analogue to _from_sequence, allowing only sequences of scalars
393+
that should be specifically inferred to the given dtype.
394+
395+
Parameters
396+
----------
397+
scalars : sequence
398+
dtype : ExtensionDtype
399+
400+
Raises
401+
------
402+
TypeError or ValueError
403+
404+
Notes
405+
-----
406+
This is called in a try/except block when casting the result of a
407+
pointwise operation in ExtensionArray._cast_pointwise_result.
408+
"""
409+
try:
410+
return cls._from_sequence(scalars, dtype=dtype, copy=False)
411+
except (ValueError, TypeError):
412+
raise
413+
except Exception:
414+
warnings.warn(
415+
"_from_scalars should only raise ValueError or TypeError. "
416+
"Consider overriding _from_scalars where appropriate.",
417+
stacklevel=find_stack_level(),
418+
)
419+
raise
420+
386421
def _cast_pointwise_result(self, values) -> ArrayLike:
387422
"""
423+
Construct an ExtensionArray after a pointwise operation.
424+
388425
Cast the result of a pointwise operation (e.g. Series.map) to an
389-
array, preserve dtype_backend if possible.
426+
array. This is not required to return an ExtensionArray of the same
427+
type as self or of the same dtype. It can also return another
428+
ExtensionArray of the same "family" if you implement multiple
429+
ExtensionArrays/Dtypes that are interoperable (e.g. if you have float
430+
array with units, this method can return an int array with units).
431+
432+
If converting to your own ExtensionArray is not possible, this method
433+
falls back to returning an array with the default type inference.
434+
If you only need to cast to `self.dtype`, it is recommended to override
435+
`_from_scalars` instead of this method.
436+
437+
Parameters
438+
----------
439+
values : sequence
440+
441+
Returns
442+
-------
443+
ExtensionArray or ndarray
390444
"""
391-
values = np.asarray(values, dtype=object)
392-
return lib.maybe_convert_objects(values, convert_non_numeric=True)
445+
try:
446+
return type(self)._from_scalars(values, dtype=self.dtype)
447+
except (ValueError, TypeError):
448+
values = np.asarray(values, dtype=object)
449+
return lib.maybe_convert_objects(values, convert_non_numeric=True)
393450

394451
# ------------------------------------------------------------------------
395452
# Must be a Sequence

0 commit comments

Comments
 (0)