Future warning on index
It looks like when we declare an explicit index, it will no longer be possible to call the implicit index with the same syntax (example with series_c[1]
).
FutureWarning: 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]`
instead, use series_c.iloc[1]
Hi Frederic!
Thanks for reaching out.
In recent versions of pandas, if you have explicitly set an index for a Series, accessing elements using `series_c[1]` (where `1` is an integer) may generate a FutureWarning. This is because pandas is moving towards a behavior where integers in `[]` will always be interpreted as labels, not positions, to be consistent with DataFrame behavior.
To access elements by position in such cases, you should use `series_c.iloc[1]`. The `.iloc` accessor is specifically designed for position-based indexing, regardless of the index labels.
Hope this helps.
Best,
Tsvetelin