Skip to content

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