Skip to content

Commit 4503bb3

Browse files
authored
Merge branch 'main' into doc/clarify-categorical-map
2 parents edc9b23 + d4bac86 commit 4503bb3

Some content is hidden

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

54 files changed

+435
-323
lines changed

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ jobs:
358358
359359
- name: Run Tests
360360
uses: ./.github/actions/run-tests
361-
# TEMP allow this to fail until we fixed all test failures (related to chained assignment warnings)
362-
continue-on-error: true
363361

364362
# NOTE: this job must be kept in sync with the Pyodide build job in wheels.yml
365363
emscripten:

doc/source/whatsnew/v3.0.0.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ Other API changes
603603
an empty ``RangeIndex`` or empty ``Index`` with object dtype when determining
604604
the dtype of the resulting Index (:issue:`60797`)
605605
- :class:`IncompatibleFrequency` now subclasses ``TypeError`` instead of ``ValueError``. As a result, joins with mismatched frequencies now cast to object like other non-comparable joins, and arithmetic with indexes with mismatched frequencies align (:issue:`55782`)
606+
- :meth:`CategoricalIndex.append` no longer attempts to cast different-dtype indexes to the caller's dtype (:issue:`41626`)
606607
- :meth:`ExtensionDtype.construct_array_type` is now a regular method instead of a ``classmethod`` (:issue:`58663`)
607608
- Comparison operations between :class:`Index` and :class:`Series` now consistently return :class:`Series` regardless of which object is on the left or right (:issue:`36759`)
608609
- 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`)
@@ -974,8 +975,8 @@ Indexing
974975
- Bug in reindexing of :class:`DataFrame` with :class:`PeriodDtype` columns in case of consolidated block (:issue:`60980`, :issue:`60273`)
975976
- 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`)
976977
- Bug in :meth:`Index.__getitem__` incorrectly raising with a 0-dim ``np.ndarray`` key (:issue:`55601`)
978+
- 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`)
977979
- Bug in indexing on a :class:`DatetimeIndex` with a ``timestamp[pyarrow]`` dtype or on a :class:`TimedeltaIndex` with a ``duration[pyarrow]`` dtype (:issue:`62277`)
978-
-
979980

980981
Missing
981982
^^^^^^^
@@ -1083,6 +1084,7 @@ Reshaping
10831084
- Bug in :meth:`DataFrame.join` when a :class:`DataFrame` with a :class:`MultiIndex` would raise an ``AssertionError`` when :attr:`MultiIndex.names` contained ``None``. (:issue:`58721`)
10841085
- Bug in :meth:`DataFrame.merge` where merging on a column containing only ``NaN`` values resulted in an out-of-bounds array access (:issue:`59421`)
10851086
- Bug in :meth:`DataFrame.unstack` producing incorrect results when ``sort=False`` (:issue:`54987`, :issue:`55516`)
1087+
- Bug in :meth:`DataFrame.unstack` raising an error with indexes containing ``NaN`` with ``sort=False`` (:issue:`61221`)
10861088
- Bug in :meth:`DataFrame.merge` when merging two :class:`DataFrame` on ``intc`` or ``uintc`` types on Windows (:issue:`60091`, :issue:`58713`)
10871089
- Bug in :meth:`DataFrame.pivot_table` incorrectly subaggregating results when called without an ``index`` argument (:issue:`58722`)
10881090
- Bug in :meth:`DataFrame.pivot_table` incorrectly ignoring the ``values`` argument when also supplied to the ``index`` or ``columns`` parameters (:issue:`57876`, :issue:`61292`)
@@ -1093,7 +1095,7 @@ Reshaping
10931095
- Bug in :func:`melt` where calling with duplicate column names in ``id_vars`` raised a misleading ``AttributeError`` (:issue:`61475`)
10941096
- Bug in :meth:`DataFrame.merge` where user-provided suffixes could result in duplicate column names if the resulting names matched existing columns. Now raises a :class:`MergeError` in such cases. (:issue:`61402`)
10951097
- Bug in :meth:`DataFrame.merge` with :class:`CategoricalDtype` columns incorrectly raising ``RecursionError`` (:issue:`56376`)
1096-
-
1098+
- Bug in :meth:`DataFrame.merge` with a ``float32`` index incorrectly casting the index to ``float64`` (:issue:`41626`)
10971099

10981100
Sparse
10991101
^^^^^^

environment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ dependencies:
9191
- sphinx
9292
- sphinx-design
9393
- sphinx-copybutton
94+
95+
# static typing
96+
- scipy-stubs
9497
- types-python-dateutil
9598
- types-PyMySQL
9699
- types-pytz

pandas/_testing/asserters.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,19 +584,13 @@ def raise_assert_detail(
584584

585585
if isinstance(left, np.ndarray):
586586
left = pprint_thing(left)
587-
elif isinstance(left, (CategoricalDtype, NumpyEADtype)):
587+
elif isinstance(left, (CategoricalDtype, StringDtype, NumpyEADtype)):
588588
left = repr(left)
589-
elif isinstance(left, StringDtype):
590-
# TODO(infer_string) this special case could be avoided if we have
591-
# a more informative repr https://github.com/pandas-dev/pandas/issues/59342
592-
left = f"StringDtype(storage={left.storage}, na_value={left.na_value})"
593589

594590
if isinstance(right, np.ndarray):
595591
right = pprint_thing(right)
596-
elif isinstance(right, (CategoricalDtype, NumpyEADtype)):
592+
elif isinstance(right, (CategoricalDtype, StringDtype, NumpyEADtype)):
597593
right = repr(right)
598-
elif isinstance(right, StringDtype):
599-
right = f"StringDtype(storage={right.storage}, na_value={right.na_value})"
600594

601595
msg += f"""
602596
[left]: {left}

pandas/_testing/contexts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
)
1313
import uuid
1414

15-
from pandas.compat import PYPY
15+
from pandas.compat import (
16+
PYPY,
17+
WARNING_CHECK_DISABLED,
18+
)
1619
from pandas.errors import ChainedAssignmentError
1720

1821
from pandas.io.common import get_handle
@@ -163,7 +166,7 @@ def with_csv_dialect(name: str, **kwargs) -> Generator[None]:
163166
def raises_chained_assignment_error(extra_warnings=(), extra_match=()):
164167
from pandas._testing import assert_produces_warning
165168

166-
if PYPY:
169+
if PYPY or WARNING_CHECK_DISABLED:
167170
if not extra_warnings:
168171
from contextlib import nullcontext
169172

pandas/compat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
PY312,
2222
PY314,
2323
PYPY,
24+
WARNING_CHECK_DISABLED,
2425
WASM,
2526
)
2627
from pandas.compat.numpy import is_numpy_dev
@@ -158,6 +159,7 @@ def is_ci_environment() -> bool:
158159
"PY314",
159160
"PYARROW_MIN_VERSION",
160161
"PYPY",
162+
"WARNING_CHECK_DISABLED",
161163
"WASM",
162164
"is_numpy_dev",
163165
"pa_version_under14p0",

pandas/compat/_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"])
2020
ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")
2121
REF_COUNT = 2
22+
WARNING_CHECK_DISABLED = PY314
23+
2224

2325
__all__ = [
2426
"IS64",

pandas/core/arrays/boolean.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
lib,
1515
missing as libmissing,
1616
)
17+
from pandas.util._decorators import set_module
1718

1819
from pandas.core.dtypes.common import is_list_like
1920
from pandas.core.dtypes.dtypes import register_extension_dtype
@@ -39,6 +40,7 @@
3940

4041

4142
@register_extension_dtype
43+
@set_module("pandas")
4244
class BooleanDtype(BaseMaskedDtype):
4345
"""
4446
Extension dtype for boolean data.

pandas/core/arrays/floating.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import numpy as np
1010

11+
from pandas.util._decorators import set_module
12+
1113
from pandas.core.dtypes.base import register_extension_dtype
1214
from pandas.core.dtypes.common import is_float_dtype
1315

@@ -168,13 +170,15 @@ class FloatingArray(NumericArray):
168170

169171

170172
@register_extension_dtype
173+
@set_module("pandas")
171174
class Float32Dtype(FloatingDtype):
172175
type = np.float32
173176
name: ClassVar[str] = "Float32"
174177
__doc__ = _dtype_docstring.format(dtype="float32")
175178

176179

177180
@register_extension_dtype
181+
@set_module("pandas")
178182
class Float64Dtype(FloatingDtype):
179183
type = np.float64
180184
name: ClassVar[str] = "Float64"

pandas/core/arrays/integer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import numpy as np
1010

11+
from pandas.util._decorators import set_module
12+
1113
from pandas.core.dtypes.base import register_extension_dtype
1214
from pandas.core.dtypes.common import is_integer_dtype
1315

@@ -218,55 +220,63 @@ class IntegerArray(NumericArray):
218220

219221

220222
@register_extension_dtype
223+
@set_module("pandas")
221224
class Int8Dtype(IntegerDtype):
222225
type = np.int8
223226
name: ClassVar[str] = "Int8"
224227
__doc__ = _dtype_docstring.format(dtype="int8")
225228

226229

227230
@register_extension_dtype
231+
@set_module("pandas")
228232
class Int16Dtype(IntegerDtype):
229233
type = np.int16
230234
name: ClassVar[str] = "Int16"
231235
__doc__ = _dtype_docstring.format(dtype="int16")
232236

233237

234238
@register_extension_dtype
239+
@set_module("pandas")
235240
class Int32Dtype(IntegerDtype):
236241
type = np.int32
237242
name: ClassVar[str] = "Int32"
238243
__doc__ = _dtype_docstring.format(dtype="int32")
239244

240245

241246
@register_extension_dtype
247+
@set_module("pandas")
242248
class Int64Dtype(IntegerDtype):
243249
type = np.int64
244250
name: ClassVar[str] = "Int64"
245251
__doc__ = _dtype_docstring.format(dtype="int64")
246252

247253

248254
@register_extension_dtype
255+
@set_module("pandas")
249256
class UInt8Dtype(IntegerDtype):
250257
type = np.uint8
251258
name: ClassVar[str] = "UInt8"
252259
__doc__ = _dtype_docstring.format(dtype="uint8")
253260

254261

255262
@register_extension_dtype
263+
@set_module("pandas")
256264
class UInt16Dtype(IntegerDtype):
257265
type = np.uint16
258266
name: ClassVar[str] = "UInt16"
259267
__doc__ = _dtype_docstring.format(dtype="uint16")
260268

261269

262270
@register_extension_dtype
271+
@set_module("pandas")
263272
class UInt32Dtype(IntegerDtype):
264273
type = np.uint32
265274
name: ClassVar[str] = "UInt32"
266275
__doc__ = _dtype_docstring.format(dtype="uint32")
267276

268277

269278
@register_extension_dtype
279+
@set_module("pandas")
270280
class UInt64Dtype(IntegerDtype):
271281
type = np.uint64
272282
name: ClassVar[str] = "UInt64"

0 commit comments

Comments
 (0)