Skip to content

CLN: MultiIndex._values remove special casing for Timestamp.freq #49559

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 1 commit into from
Nov 6, 2022
Merged
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
12 changes: 1 addition & 11 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,23 +732,13 @@ def _values(self) -> np.ndarray:
vals = cast("CategoricalIndex", vals)
vals = vals._data._internal_get_values()

is_dti = isinstance(vals, ABCDatetimeIndex)

if is_dti:
# TODO: this can be removed after Timestamp.freq is removed
# The astype(object) below does not remove the freq from
# the underlying Timestamps so we remove it here to match
# the behavior of self._get_level_values
vals = algos.take_nd(vals, codes, fill_value=index._na_value)

if isinstance(vals.dtype, ExtensionDtype) or isinstance(
vals, (ABCDatetimeIndex, ABCTimedeltaIndex)
):
vals = vals.astype(object)

vals = np.array(vals, copy=False)
if not is_dti:
vals = algos.take_nd(vals, codes, fill_value=index._na_value)
vals = algos.take_nd(vals, codes, fill_value=index._na_value)
values.append(vals)

arr = lib.fast_zip(values)
Expand Down