Skip to content

Commit ee92b7b

Browse files
authored
Merge branch 'main' into gh-62717
2 parents ea2c206 + 9991295 commit ee92b7b

File tree

49 files changed

+1753
-1055
lines changed

Some content is hidden

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

49 files changed

+1753
-1055
lines changed

.github/workflows/unit-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ jobs:
181181
timeout-minutes: 90
182182
strategy:
183183
matrix:
184-
# Note: Don't use macOS latest since macos 14 appears to be arm64 only
185-
os: [macos-13, macos-14, windows-2025]
184+
os: [macos-15-intel, macos-15, windows-2025]
186185
env_file: [actions-311.yaml, actions-312.yaml, actions-313.yaml]
187186
fail-fast: false
188187
runs-on: ${{ matrix.os }}
@@ -399,7 +398,7 @@ jobs:
399398
pyodide build
400399
401400
- name: Set up Node.js
402-
uses: actions/setup-node@v5
401+
uses: actions/setup-node@v6
403402
with:
404403
node-version: '20'
405404

.github/workflows/wheels.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ jobs:
9898
- [ubuntu-24.04, musllinux_x86_64]
9999
- [ubuntu-24.04-arm, manylinux_aarch64]
100100
- [ubuntu-24.04-arm, musllinux_aarch64]
101-
- [macos-13, macosx_x86_64]
102-
# Note: M1 images on Github Actions start from macOS 14
103-
- [macos-14, macosx_arm64]
104-
- [windows-2022, win_amd64]
101+
- [macos-15-intel, macosx_x86_64]
102+
- [macos-15, macosx_arm64]
103+
- [windows-2025, win_amd64]
105104
- [windows-11-arm, win_arm64]
106105
python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "3.14"], ["cp314t", "3.14"]]
107106
include:

asv_bench/benchmarks/ctors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def gen_of_str(arr):
2323

2424

2525
def arr_dict(arr):
26-
return dict(zip(range(len(arr)), arr))
26+
return dict(zip(range(len(arr)), arr, strict=True))
2727

2828

2929
def list_of_tuples(arr):

asv_bench/benchmarks/series_methods.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def setup(self):
1616
self.idx = date_range(
1717
start=datetime(2015, 10, 26), end=datetime(2016, 1, 1), freq="50s"
1818
)
19-
self.data = dict(zip(self.idx, range(len(self.idx))))
19+
self.data = dict(zip(self.idx, range(len(self.idx)), strict=True))
2020
self.array = np.array([1, 2, 3])
2121
self.idx2 = Index(["a", "b", "c"])
2222

@@ -407,7 +407,9 @@ def setup(self, num_to_replace):
407407
self.to_replace_list = np.random.choice(self.arr, num_to_replace)
408408
self.values_list = np.random.choice(self.arr1, num_to_replace)
409409

410-
self.replace_dict = dict(zip(self.to_replace_list, self.values_list))
410+
self.replace_dict = dict(
411+
zip(self.to_replace_list, self.values_list, strict=True)
412+
)
411413

412414
def time_replace_dict(self, num_to_replace):
413415
self.ser.replace(self.replace_dict)

doc/source/whatsnew/v3.0.0.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,22 @@ If we had passed ``pd.Int64Dtype()`` or ``"int64[pyarrow]"`` for the dtype in th
515515

516516
With ``"mode.nan_is_na"`` set to ``False``, ``ser.to_numpy()`` (and ``frame.values`` and ``np.asarray(obj)``) will convert to ``object`` dtype if :class:`NA` entries are present, where before they would coerce to ``NaN``. To retain a float numpy dtype, explicitly pass ``na_value=np.nan`` to :meth:`Series.to_numpy`.
517517

518+
The ``__module__`` attribute now points to public modules
519+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
520+
521+
The ``__module__`` attribute on functions and classes in the public API has been
522+
updated to refer to the preferred public module from which to access the object,
523+
rather than the module in which the object happens to be defined (:issue:`55178`).
524+
525+
This produces more informative displays in the Python console for classes, e.g.,
526+
instead of ``<class 'pandas.core.frame.DataFrame'>`` you now see
527+
``<class 'pandas.DataFrame'>``, and in interactive tools such as IPython, e.g.,
528+
instead of ``<function pandas.io.parsers.readers.read_csv(...)>`` you now see
529+
``<function pandas.read_csv(...)>``.
530+
531+
This may break code that relies on the previous ``__module__`` values (e.g.
532+
doctests inspecting the ``type()`` of a DataFrame object).
533+
518534
.. _whatsnew_300.api_breaking.deps:
519535

520536
Increased minimum version for Python
@@ -938,6 +954,7 @@ Bug fixes
938954

939955
Categorical
940956
^^^^^^^^^^^
957+
- Bug in :class:`Categorical` where constructing from a pandas :class:`Series` or :class:`Index` with ``dtype='object'`` did not preserve the categories' dtype as ``object``; now the ``categories.dtype`` is preserved as ``object`` for these cases, while numpy arrays and Python sequences with ``dtype='object'`` continue to infer the most specific dtype (for example, ``str`` if all elements are strings) (:issue:`61778`)
941958
- Bug in :func:`Series.apply` where ``nan`` was ignored for :class:`CategoricalDtype` (:issue:`59938`)
942959
- Bug in :func:`testing.assert_index_equal` raising ``TypeError`` instead of ``AssertionError`` for incomparable ``CategoricalIndex`` when ``check_categorical=True`` and ``exact=False`` (:issue:`61935`)
943960
- Bug in :meth:`Categorical.astype` where ``copy=False`` would still trigger a copy of the codes (:issue:`62000`)
@@ -1041,6 +1058,7 @@ Indexing
10411058
- Bug in reindexing of :class:`DataFrame` with :class:`PeriodDtype` columns in case of consolidated block (:issue:`60980`, :issue:`60273`)
10421059
- 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`)
10431060
- Bug in :meth:`Index.__getitem__` incorrectly raising with a 0-dim ``np.ndarray`` key (:issue:`55601`)
1061+
- Bug in :meth:`Index.get_indexer` not casting missing values correctly for new string datatype (:issue:`55833`)
10441062
- 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`)
10451063
- Bug in indexing on a :class:`DatetimeIndex` with a ``timestamp[pyarrow]`` dtype or on a :class:`TimedeltaIndex` with a ``duration[pyarrow]`` dtype (:issue:`62277`)
10461064

@@ -1086,6 +1104,7 @@ I/O
10861104
- Bug in :meth:`HDFStore.select` causing queries on categorical string columns to return unexpected results (:issue:`57608`)
10871105
- Bug in :meth:`MultiIndex.factorize` incorrectly raising on length-0 indexes (:issue:`57517`)
10881106
- Bug in :meth:`read_csv` causing segmentation fault when ``encoding_errors`` is not a string. (:issue:`59059`)
1107+
- Bug in :meth:`read_csv` for the ``c`` and ``python`` engines where parsing numbers with large exponents caused overflows. Now, numbers with large positive exponents are parsed as ``inf`` or ``-inf`` depending on the sign of the mantissa, while those with large negative exponents are parsed as ``0.0`` (:issue:`62617`, :issue:`38794`, :issue:`62740`)
10891108
- Bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)
10901109
- Bug in :meth:`read_csv` raising ``TypeError`` when ``nrows`` and ``iterator`` are specified without specifying a ``chunksize``. (:issue:`59079`)
10911110
- Bug in :meth:`read_csv` where the order of the ``na_values`` makes an inconsistency when ``na_values`` is a list non-string values. (:issue:`59303`)
@@ -1147,7 +1166,6 @@ Groupby/resample/rolling
11471166
- Bug in :meth:`Rolling.apply` for ``method="table"`` where column order was not being respected due to the columns getting sorted by default. (:issue:`59666`)
11481167
- Bug in :meth:`Rolling.apply` where the applied function could be called on fewer than ``min_period`` periods if ``method="table"``. (:issue:`58868`)
11491168
- Bug in :meth:`Series.resample` could raise when the date range ended shortly before a non-existent time. (:issue:`58380`)
1150-
- Bug in :meth:`Series.rolling.var` and :meth:`Series.rolling.std` where the end of window was not indexed correctly. (:issue:`47721`, :issue:`52407`, :issue:`54518`, :issue:`55343`)
11511169

11521170
Reshaping
11531171
^^^^^^^^^

pandas/_config/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,3 +944,11 @@ def is_callable(obj: object) -> bool:
944944
if not callable(obj):
945945
raise ValueError("Value must be a callable")
946946
return True
947+
948+
949+
# import set_module here would cause circular import
950+
get_option.__module__ = "pandas"
951+
set_option.__module__ = "pandas"
952+
describe_option.__module__ = "pandas"
953+
reset_option.__module__ = "pandas"
954+
option_context.__module__ = "pandas"

pandas/_libs/include/pandas/portable.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,51 @@ The full license is in the LICENSE file, distributed with this software.
3535
do { \
3636
} while (0) /* fallthrough */
3737
#endif
38+
39+
#if defined(_WIN32)
40+
#ifndef ENABLE_INTSAFE_SIGNED_FUNCTIONS
41+
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
42+
#endif
43+
#include <intsafe.h>
44+
#define checked_add(a, b, res) \
45+
_Generic((res), \
46+
int *: IntAdd, \
47+
unsigned int *: UIntAdd, \
48+
long *: LongAdd, \
49+
unsigned long *: ULongAdd, \
50+
long long *: LongLongAdd, \
51+
unsigned long long *: ULongLongAdd, \
52+
short *: ShortAdd, \
53+
unsigned short *: UShortAdd)(a, b, res)
54+
55+
#define checked_sub(a, b, res) \
56+
_Generic((res), \
57+
int *: IntSub, \
58+
unsigned int *: UIntSub, \
59+
long *: LongSub, \
60+
unsigned long *: ULongSub, \
61+
long long *: LongLongSub, \
62+
unsigned long long *: ULongLongSub, \
63+
short *: ShortSub, \
64+
unsigned short *: UShortSub)(a, b, res)
65+
66+
#define checked_mul(a, b, res) \
67+
_Generic((res), \
68+
int *: IntMult, \
69+
unsigned int *: UIntMult, \
70+
long *: LongMult, \
71+
unsigned long *: ULongMult, \
72+
long long *: LongLongMult, \
73+
unsigned long long *: ULongLongMult, \
74+
short *: ShortMult, \
75+
unsigned short *: UShortMult)(a, b, res)
76+
77+
#elif (defined(__has_builtin) && __has_builtin(__builtin_add_overflow)) || \
78+
__GNUC__ > 7
79+
#define checked_add(a, b, res) __builtin_add_overflow(a, b, res)
80+
#define checked_sub(a, b, res) __builtin_sub_overflow(a, b, res)
81+
#define checked_mul(a, b, res) __builtin_mul_overflow(a, b, res)
82+
#else
83+
_Static_assert(0,
84+
"Overflow checking not detected; please try a newer compiler");
85+
#endif

pandas/_libs/lib.pyx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ from cython cimport (
4141
from pandas._config import using_string_dtype
4242

4343
from pandas._libs.missing import check_na_tuples_nonequal
44+
from pandas.util._decorators import set_module
4445

4546
import_datetime()
4647

@@ -154,6 +155,7 @@ def memory_usage_of_objects(arr: object[:]) -> int64_t:
154155
# ----------------------------------------------------------------------
155156

156157

158+
@set_module("pandas.api.types")
157159
def is_scalar(val: object) -> bool:
158160
"""
159161
Return True if given object is scalar.
@@ -255,6 +257,7 @@ cdef int64_t get_itemsize(object val):
255257
return -1
256258

257259

260+
@set_module("pandas.api.types")
258261
def is_iterator(obj: object) -> bool:
259262
"""
260263
Check if the object is an iterator.
@@ -1095,6 +1098,7 @@ def indices_fast(ndarray[intp_t, ndim=1] index, const int64_t[:] labels, list ke
10951098

10961099
# core.common import for fast inference checks
10971100

1101+
@set_module("pandas.api.types")
10981102
def is_float(obj: object) -> bool:
10991103
"""
11001104
Return True if given object is float.
@@ -1128,6 +1132,7 @@ def is_float(obj: object) -> bool:
11281132
return util.is_float_object(obj)
11291133

11301134

1135+
@set_module("pandas.api.types")
11311136
def is_integer(obj: object) -> bool:
11321137
"""
11331138
Return True if given object is integer.
@@ -1172,6 +1177,7 @@ def is_int_or_none(obj) -> bool:
11721177
return obj is None or util.is_integer_object(obj)
11731178

11741179

1180+
@set_module("pandas.api.types")
11751181
def is_bool(obj: object) -> bool:
11761182
"""
11771183
Return True if given object is boolean.
@@ -1202,6 +1208,7 @@ def is_bool(obj: object) -> bool:
12021208
return util.is_bool_object(obj)
12031209

12041210

1211+
@set_module("pandas.api.types")
12051212
def is_complex(obj: object) -> bool:
12061213
"""
12071214
Return True if given object is complex.
@@ -1237,6 +1244,7 @@ cpdef bint is_decimal(object obj):
12371244
return isinstance(obj, Decimal)
12381245

12391246

1247+
@set_module("pandas.api.types")
12401248
def is_list_like(obj: object, allow_sets: bool = True) -> bool:
12411249
"""
12421250
Check if the object is list-like.
@@ -1520,6 +1528,7 @@ cdef object _try_infer_map(object dtype):
15201528
return None
15211529

15221530

1531+
@set_module("pandas.api.types")
15231532
def infer_dtype(value: object, skipna: bool = True) -> str:
15241533
"""
15251534
Return a string label of the type of the elements in a list-like input.

0 commit comments

Comments
 (0)