Skip to content

Commit 9721fc3

Browse files
Merge branch 'main' into fix-59242
2 parents 30ce3b3 + 5b16c06 commit 9721fc3

File tree

16 files changed

+42
-24
lines changed

16 files changed

+42
-24
lines changed

doc/source/user_guide/cookbook.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ CSV
10431043

10441044
The :ref:`CSV <io.read_csv_table>` docs
10451045

1046-
`read_csv in action <https://wesmckinney.com/blog/update-on-upcoming-pandas-v0-10-new-file-parser-other-performance-wins/>`__
1046+
`read_csv in action <https://www.datacamp.com/tutorial/pandas-read-csv>`__
10471047

10481048
`appending to a csv
10491049
<https://stackoverflow.com/questions/17134942/pandas-dataframe-output-end-of-csv>`__

doc/source/user_guide/enhancingperf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ prefer that Numba throw an error if it cannot compile a function in a way that
427427
speeds up your code, pass Numba the argument
428428
``nopython=True`` (e.g. ``@jit(nopython=True)``). For more on
429429
troubleshooting Numba modes, see the `Numba troubleshooting page
430-
<https://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#the-compiled-code-is-too-slow>`__.
430+
<https://numba.readthedocs.io/en/stable/user/troubleshoot.html>`__.
431431

432432
Using ``parallel=True`` (e.g. ``@jit(parallel=True)``) may result in a ``SIGABRT`` if the threading layer leads to unsafe
433433
behavior. You can first `specify a safe threading layer <https://numba.readthedocs.io/en/stable/user/threading-layer.html#selecting-a-threading-layer-for-safe-parallel-execution>`__

doc/source/user_guide/pyarrow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Data Structure Integration
2222

2323
A :class:`Series`, :class:`Index`, or the columns of a :class:`DataFrame` can be directly backed by a :external+pyarrow:py:class:`pyarrow.ChunkedArray`
2424
which is similar to a NumPy array. To construct these from the main pandas data structures, you can pass in a string of the type followed by
25-
``[pyarrow]``, e.g. ``"int64[pyarrow]""`` into the ``dtype`` parameter
25+
``[pyarrow]``, e.g. ``"int64[pyarrow]"`` into the ``dtype`` parameter
2626

2727
.. ipython:: python
2828

pandas/_config/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def get_option(pat: str) -> Any:
141141
"""
142142
Retrieve the value of the specified option.
143143
144+
This method allows users to query the current value of a given option
145+
in the pandas configuration system. Options control various display,
146+
performance, and behavior-related settings within pandas.
147+
144148
Parameters
145149
----------
146150
pat : str

pandas/core/arraylike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def array_ufunc(self, ufunc: np.ufunc, method: str, *inputs: Any, **kwargs: Any)
329329
reconstruct_axes = dict(zip(self._AXIS_ORDERS, self.axes))
330330

331331
if self.ndim == 1:
332-
names = {getattr(x, "name") for x in inputs if hasattr(x, "name")}
332+
names = {x.name for x in inputs if hasattr(x, "name")}
333333
name = names.pop() if len(names) == 1 else None
334334
reconstruct_kwargs = {"name": name}
335335
else:

pandas/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def is_full_slice(obj, line: int) -> bool:
359359
def get_callable_name(obj):
360360
# typical case has name
361361
if hasattr(obj, "__name__"):
362-
return getattr(obj, "__name__")
362+
return obj.__name__
363363
# some objects don't; could recurse
364364
if isinstance(obj, partial):
365365
return get_callable_name(obj.func)

pandas/core/dtypes/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,8 @@ def pandas_dtype(dtype) -> DtypeObj:
18361836
# raise a consistent TypeError if failed
18371837
try:
18381838
with warnings.catch_warnings():
1839+
# TODO: warnings.catch_warnings can be removed when numpy>2.2.2
1840+
# is the minimum version
18391841
# GH#51523 - Series.astype(np.integer) doesn't show
18401842
# numpy deprecation warning of np.integer
18411843
# Hence enabling DeprecationWarning

pandas/io/formats/style.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ def apply(
20212021
more details.
20222022
"""
20232023
self._todo.append(
2024-
(lambda instance: getattr(instance, "_apply"), (func, axis, subset), kwargs)
2024+
(lambda instance: instance._apply, (func, axis, subset), kwargs)
20252025
)
20262026
return self
20272027

@@ -2128,7 +2128,7 @@ def apply_index(
21282128
"""
21292129
self._todo.append(
21302130
(
2131-
lambda instance: getattr(instance, "_apply_index"),
2131+
lambda instance: instance._apply_index,
21322132
(func, axis, level, "apply"),
21332133
kwargs,
21342134
)
@@ -2157,7 +2157,7 @@ def map_index(
21572157
) -> Styler:
21582158
self._todo.append(
21592159
(
2160-
lambda instance: getattr(instance, "_apply_index"),
2160+
lambda instance: instance._apply_index,
21612161
(func, axis, level, "map"),
21622162
kwargs,
21632163
)
@@ -2230,9 +2230,7 @@ def map(self, func: Callable, subset: Subset | None = None, **kwargs) -> Styler:
22302230
See `Table Visualization <../../user_guide/style.ipynb>`_ user guide for
22312231
more details.
22322232
"""
2233-
self._todo.append(
2234-
(lambda instance: getattr(instance, "_map"), (func, subset), kwargs)
2235-
)
2233+
self._todo.append((lambda instance: instance._map, (func, subset), kwargs))
22362234
return self
22372235

22382236
def set_table_attributes(self, attributes: str) -> Styler:

pandas/tests/dtypes/test_common.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import pandas._testing as tm
2323
from pandas.api.types import pandas_dtype
2424
from pandas.arrays import SparseArray
25+
from pandas.util.version import Version
2526

2627

2728
# EA & Actual Dtypes
@@ -788,11 +789,18 @@ def test_validate_allhashable():
788789

789790
def test_pandas_dtype_numpy_warning():
790791
# GH#51523
791-
with tm.assert_produces_warning(
792-
DeprecationWarning,
793-
check_stacklevel=False,
794-
match="Converting `np.integer` or `np.signedinteger` to a dtype is deprecated",
795-
):
792+
if Version(np.__version__) <= Version("2.2.2"):
793+
ctx = tm.assert_produces_warning(
794+
DeprecationWarning,
795+
check_stacklevel=False,
796+
match=(
797+
"Converting `np.integer` or `np.signedinteger` to a dtype is deprecated"
798+
),
799+
)
800+
else:
801+
ctx = tm.external_error_raised(TypeError)
802+
803+
with ctx:
796804
pandas_dtype(np.integer)
797805

798806

pandas/tests/generic/test_finalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def test_timedelta_methods(method):
644644
operator.methodcaller("add_categories", ["c"]),
645645
operator.methodcaller("as_ordered"),
646646
operator.methodcaller("as_unordered"),
647-
lambda x: getattr(x, "codes"),
647+
lambda x: x.codes,
648648
operator.methodcaller("remove_categories", "a"),
649649
operator.methodcaller("remove_unused_categories"),
650650
operator.methodcaller("rename_categories", {"a": "A", "b": "B"}),

pandas/tests/groupby/test_apply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def test_empty_df(method, op):
13901390
# GH 47985
13911391
empty_df = DataFrame({"a": [], "b": []})
13921392
gb = empty_df.groupby("a", group_keys=True)
1393-
group = getattr(gb, "b")
1393+
group = gb.b
13941394

13951395
result = getattr(group, method)(op)
13961396
expected = Series(

pandas/tests/groupby/test_groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def test_attr_wrapper(ts):
264264
# make sure raises error
265265
msg = "'SeriesGroupBy' object has no attribute 'foo'"
266266
with pytest.raises(AttributeError, match=msg):
267-
getattr(grouped, "foo")
267+
grouped.foo
268268

269269

270270
def test_frame_groupby(tsframe):

pandas/tests/io/pytables/test_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def test_getattr(setup_path):
311311
# test attribute access
312312
result = store.a
313313
tm.assert_series_equal(result, s)
314-
result = getattr(store, "a")
314+
result = store.a
315315
tm.assert_series_equal(result, s)
316316

317317
df = DataFrame(

pandas/tests/test_downstream.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
TimedeltaIndex,
2121
)
2222
import pandas._testing as tm
23+
from pandas.util.version import Version
2324

2425

2526
@pytest.fixture
@@ -222,15 +223,22 @@ def test_missing_required_dependency():
222223
assert name in output
223224

224225

225-
def test_frame_setitem_dask_array_into_new_col():
226+
def test_frame_setitem_dask_array_into_new_col(request):
226227
# GH#47128
227228

228229
# dask sets "compute.use_numexpr" to False, so catch the current value
229230
# and ensure to reset it afterwards to avoid impacting other tests
230231
olduse = pd.get_option("compute.use_numexpr")
231232

232233
try:
234+
dask = pytest.importorskip("dask")
233235
da = pytest.importorskip("dask.array")
236+
if Version(dask.__version__) <= Version("2025.1.0") and Version(
237+
np.__version__
238+
) >= Version("2.1"):
239+
request.applymarker(
240+
pytest.mark.xfail(reason="loc.__setitem__ incorrectly mutated column c")
241+
)
234242

235243
dda = da.array([1, 2])
236244
df = DataFrame({"a": ["a", "b"]})

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ ignore = [
272272
"B007",
273273
# controversial
274274
"B008",
275-
# setattr is used to side-step mypy
276-
"B009",
277275
# getattr is used to side-step mypy
278276
"B010",
279277
# tests use comparisons but not their returned value

web/pandas/community/ecosystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ developers to build powerful and more focused data tools. The creation
88
of libraries that complement pandas' functionality also allows pandas
99
development to remain focused around its original requirements.
1010

11-
This is an community-maintained list of projects that build on pandas in order
11+
This is a community-maintained list of projects that build on pandas in order
1212
to provide tools in the PyData space. The pandas core development team does not necessarily endorse any particular project on this list or have any knowledge of the maintenance status of any particular library.
1313

1414
For a more complete list of projects that depend on pandas, see the [libraries.io usage page for

0 commit comments

Comments
 (0)