Skip to content

Commit 14f9184

Browse files
Temporarily add back Index._get_attributes_dict for dask compat (#44028)
1 parent ef49a8e commit 14f9184

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pandas/core/indexes/base.py

+16
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,22 @@ def _format_duplicate_message(self) -> DataFrame:
731731
# --------------------------------------------------------------------
732732
# Index Internals Methods
733733

734+
@final
735+
def _get_attributes_dict(self) -> dict[str_t, Any]:
736+
"""
737+
Return an attributes dict for my class.
738+
739+
Temporarily added back for compatibility issue in dask, see
740+
https://github.com/pandas-dev/pandas/pull/43895
741+
"""
742+
warnings.warn(
743+
"The Index._get_attributes_dict method is deprecated, and will be "
744+
"removed in a future version",
745+
DeprecationWarning,
746+
stacklevel=2,
747+
)
748+
return {k: getattr(self, k, None) for k in self._attributes}
749+
734750
def _shallow_copy(self: _IndexT, values, name: Hashable = no_default) -> _IndexT:
735751
"""
736752
Create a new Index with the same class as the caller, don't copy the

pandas/tests/indexes/test_base.py

+8
Original file line numberDiff line numberDiff line change
@@ -1788,3 +1788,11 @@ def test_drop_duplicates_pos_args_deprecation():
17881788
result = idx.drop_duplicates("last")
17891789
expected = Index([2, 3, 1])
17901790
tm.assert_index_equal(expected, result)
1791+
1792+
1793+
def test_get_attributes_dict_deprecated():
1794+
# https://github.com/pandas-dev/pandas/pull/44028
1795+
idx = Index([1, 2, 3, 1])
1796+
with tm.assert_produces_warning(DeprecationWarning):
1797+
attrs = idx._get_attributes_dict()
1798+
assert attrs == {"name": None}

0 commit comments

Comments
 (0)