Skip to content
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

Fix warning: Series.__getitem__ treating keys as positions is deprecated. #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

debnath-d
Copy link

Series.getitem treating keys as positions is deprecated.

See: pandas-dev/pandas#53201

See: https://github.com/pandas-dev/pandas/blob/2.1.x/pandas/core/series.py#L1027-L1037

if is_integer(key) and self.index._should_fallback_to_positional:
    warnings.warn(
        # GH#50617
        "Series.__getitem__ treating keys as positions is deprecated. "
        "In a future version, integer keys will always be treated "
        "as labels (consistent with DataFrame behavior). To access "
        "a value by position, use `ser.iloc[pos]`",
        FutureWarning,
        stacklevel=find_stack_level(),
    )
    return self._values[key]

@debnath-d debnath-d changed the title Update _get_column_info() Fix warning: Series.__getitem__ treating keys as positions is deprecated. Apr 30, 2024
@jonathan-taylor
Copy link
Collaborator

I think this is somewhat fixed by casting is_categorical / is_ordinal to np.ndarray

ISLP/ISLP/models/columns.py

Lines 276 to 277 in 47dd59b

is_categorical = np.asarray(is_categorical)
is_ordinal = np.asarray(is_ordinal)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants