Skip to content

Temporarily add back Index._get_attributes_dict for dask compat #44028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,22 @@ def _format_duplicate_message(self) -> DataFrame:
# --------------------------------------------------------------------
# Index Internals Methods

@final
def _get_attributes_dict(self) -> dict[str_t, Any]:
"""
Return an attributes dict for my class.

Temporarily added back for compatibility issue in dask, see
https://github.com/pandas-dev/pandas/pull/43895
"""
warnings.warn(
"The Index._get_attributes_dict method is deprecated, and will be "
"removed in a future version",
DeprecationWarning,
stacklevel=2,
)
return {k: getattr(self, k, None) for k in self._attributes}

def _shallow_copy(self: _IndexT, values, name: Hashable = no_default) -> _IndexT:
"""
Create a new Index with the same class as the caller, don't copy the
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,3 +1788,11 @@ def test_drop_duplicates_pos_args_deprecation():
result = idx.drop_duplicates("last")
expected = Index([2, 3, 1])
tm.assert_index_equal(expected, result)


def test_get_attributes_dict_deprecated():
# https://github.com/pandas-dev/pandas/pull/44028
idx = Index([1, 2, 3, 1])
with tm.assert_produces_warning(DeprecationWarning):
attrs = idx._get_attributes_dict()
assert attrs == {"name": None}