Skip to content

Commit 17fcfc1

Browse files
authored
Merge branch 'main' into issue_61863
2 parents 09245fd + 13bba34 commit 17fcfc1

File tree

8 files changed

+32
-24
lines changed

8 files changed

+32
-24
lines changed

.github/workflows/docbuild-and-upload.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ jobs:
5757
run: python web/pandas_web.py web/pandas --target-path=web/build
5858

5959
- name: Build documentation
60+
# TEMP don't let errors fail the build until all string dtype changes are fixed
61+
continue-on-error: true
6062
run: doc/make.py --warnings-are-errors
6163

6264
- name: Build the interactive terminal

.github/workflows/unit-tests.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
env_file: [actions-310.yaml, actions-311.yaml, actions-312.yaml, actions-313.yaml]
3131
# Prevent the include jobs from overriding other jobs
3232
pattern: [""]
33-
pandas_future_infer_string: ["0"]
33+
pandas_future_infer_string: ["1"]
3434
include:
3535
- name: "Downstream Compat"
3636
env_file: actions-311-downstream_compat.yaml
@@ -45,6 +45,10 @@ jobs:
4545
env_file: actions-313-freethreading.yaml
4646
pattern: "not slow and not network and not single_cpu"
4747
platform: ubuntu-24.04
48+
- name: "Without PyArrow"
49+
env_file: actions-312.yaml
50+
pattern: "not slow and not network and not single_cpu"
51+
platform: ubuntu-24.04
4852
- name: "Locale: it_IT"
4953
env_file: actions-311.yaml
5054
pattern: "not slow and not network and not single_cpu"
@@ -67,13 +71,9 @@ jobs:
6771
# It will be temporarily activated during tests with locale.setlocale
6872
extra_loc: "zh_CN"
6973
platform: ubuntu-24.04
70-
- name: "Future infer strings"
74+
- name: "Past no infer strings"
7175
env_file: actions-312.yaml
72-
pandas_future_infer_string: "1"
73-
platform: ubuntu-24.04
74-
- name: "Future infer strings (without pyarrow)"
75-
env_file: actions-311.yaml
76-
pandas_future_infer_string: "1"
76+
pandas_future_infer_string: "0"
7777
platform: ubuntu-24.04
7878
- name: "Numpy Dev"
7979
env_file: actions-311-numpydev.yaml
@@ -83,7 +83,6 @@ jobs:
8383
- name: "Pyarrow Nightly"
8484
env_file: actions-311-pyarrownightly.yaml
8585
pattern: "not slow and not network and not single_cpu"
86-
pandas_future_infer_string: "1"
8786
platform: ubuntu-24.04
8887
fail-fast: false
8988
name: ${{ matrix.name || format('{0} {1}', matrix.platform, matrix.env_file) }}
@@ -98,7 +97,7 @@ jobs:
9897
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }}
9998
# Clipboard tests
10099
QT_QPA_PLATFORM: offscreen
101-
REMOVE_PYARROW: ${{ matrix.name == 'Future infer strings (without pyarrow)' && '1' || '0' }}
100+
REMOVE_PYARROW: ${{ matrix.name == 'Without PyArrow' && '1' || '0' }}
102101
concurrency:
103102
# https://github.community/t/concurrecy-not-work-for-push/183068/7
104103
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.env_file }}-${{ matrix.pattern }}-${{ matrix.extra_apt || '' }}-${{ matrix.pandas_future_infer_string }}-${{ matrix.platform }}

ci/code_checks.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
5858

5959
MSG='Python and Cython Doctests' ; echo "$MSG"
6060
python -c 'import pandas as pd; pd.test(run_doctests=True)'
61-
RET=$(($RET + $?)) ; echo "$MSG" "DONE"
61+
# TEMP don't let doctests fail the build until all string dtype changes are fixed
62+
# RET=$(($RET + $?)) ; echo "$MSG" "DONE"
63+
echo "$MSG" "DONE"
6264

6365
fi
6466

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ Other API changes
414414
- Index set operations (like union or intersection) will now ignore the dtype of
415415
an empty ``RangeIndex`` or empty ``Index`` with object dtype when determining
416416
the dtype of the resulting Index (:issue:`60797`)
417+
- Numpy functions like ``np.isinf`` that return a bool dtype when called on a :class:`Index` object now return a bool-dtype :class:`Index` instead of ``np.ndarray`` (:issue:`52676`)
417418

418419
.. ---------------------------------------------------------------------------
419420
.. _whatsnew_300.deprecations:

pandas/core/config_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def register_converter_cb(key: str) -> None:
880880
with cf.config_prefix("future"):
881881
cf.register_option(
882882
"infer_string",
883-
True if os.environ.get("PANDAS_FUTURE_INFER_STRING", "0") == "1" else False,
883+
False if os.environ.get("PANDAS_FUTURE_INFER_STRING", "1") == "0" else True,
884884
"Whether to infer sequence of str objects as pyarrow string "
885885
"dtype, which will be the default in pandas 3.0 "
886886
"(at which point this option will be deprecated).",

pandas/core/indexes/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -965,12 +965,8 @@ def __array_wrap__(self, result, context=None, return_scalar=False):
965965
Gets called after a ufunc and other functions e.g. np.split.
966966
"""
967967
result = lib.item_from_zerodim(result)
968-
if (not isinstance(result, Index) and is_bool_dtype(result.dtype)) or np.ndim(
969-
result
970-
) > 1:
971-
# exclude Index to avoid warning from is_bool_dtype deprecation;
972-
# in the Index case it doesn't matter which path we go down.
973-
# reached in plotting tests with e.g. np.nonzero(index)
968+
if np.ndim(result) > 1:
969+
# Reached in plotting tests with e.g. np.nonzero(index)
974970
return result
975971

976972
return Index(result, name=self.name)

pandas/core/tools/numeric.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ def to_numeric(
114114
Numeric if parsing succeeded.
115115
Return type depends on input. Series if Series, otherwise ndarray.
116116
117+
Raises
118+
------
119+
ValueError
120+
If the input contains non-numeric values and `errors='raise'`.
121+
TypeError
122+
If the input is not list-like, 1D, or scalar convertible to numeric,
123+
such as nested lists or unsupported input types (e.g., dict).
124+
117125
See Also
118126
--------
119127
DataFrame.astype : Cast argument to a specified dtype.

pandas/tests/indexes/test_numpy_compat.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33

44
from pandas import (
5+
BooleanDtype,
56
CategoricalIndex,
67
DatetimeIndex,
78
Index,
@@ -14,7 +15,6 @@
1415
is_complex_dtype,
1516
is_numeric_dtype,
1617
)
17-
from pandas.core.arrays import BooleanArray
1818
from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin
1919

2020

@@ -111,11 +111,10 @@ def test_numpy_ufuncs_other(index, func):
111111
if func in (np.isfinite, np.isinf, np.isnan):
112112
# numpy 1.18 changed isinf and isnan to not raise on dt64/td64
113113
result = func(index)
114-
assert isinstance(result, np.ndarray)
115114

116115
out = np.empty(index.shape, dtype=bool)
117116
func(index, out=out)
118-
tm.assert_numpy_array_equal(out, result)
117+
tm.assert_index_equal(Index(out), result)
119118
else:
120119
with tm.external_error_raised(TypeError):
121120
func(index)
@@ -129,19 +128,20 @@ def test_numpy_ufuncs_other(index, func):
129128
):
130129
# Results in bool array
131130
result = func(index)
131+
assert isinstance(result, Index)
132132
if not isinstance(index.dtype, np.dtype):
133133
# e.g. Int64 we expect to get BooleanArray back
134-
assert isinstance(result, BooleanArray)
134+
assert isinstance(result.dtype, BooleanDtype)
135135
else:
136-
assert isinstance(result, np.ndarray)
136+
assert isinstance(result.dtype, np.dtype)
137137

138138
out = np.empty(index.shape, dtype=bool)
139139
func(index, out=out)
140140

141141
if not isinstance(index.dtype, np.dtype):
142-
tm.assert_numpy_array_equal(out, result._data)
142+
tm.assert_index_equal(result, Index(out, dtype="boolean"))
143143
else:
144-
tm.assert_numpy_array_equal(out, result)
144+
tm.assert_index_equal(result, Index(out))
145145

146146
elif len(index) == 0:
147147
pass

0 commit comments

Comments
 (0)