polars icon indicating copy to clipboard operation
polars copied to clipboard

Python: deprecate most indexing operations.

Open ritchie46 opened this issue 3 years ago • 3 comments

Which ones should we still allow?

ritchie46 avatar Jun 20 '22 09:06 ritchie46

Please keep the slicing operations. They are standard in Data Science since numpy. The easiest way to take every other row of a series or a dataframe is df[::2].

Moreover, it would be great to allow for negative steps in Series like series[::-1]. Currently, negative steps work fine for DataFrames but result in error for Series (probably a bug):

import polars as pl
sr = pl.Series(name='int', values=np.arange(10,20))
sr[::-1]
OverflowError: can't convert negative int to unsigned

slonik-az avatar Jun 21 '22 03:06 slonik-az

I agree, I want to remove predicates in index notation. That should always be a filter imo.

I want to maintain support for slicing and selection by strings/index.

ritchie46 avatar Jun 21 '22 07:06 ritchie46

I think other cases can indeed be removed. Slicing operations were greatly improved in https://github.com/pola-rs/polars/pull/3904

ghuls avatar Jul 07 '22 22:07 ghuls

I agree, I want to remove predicates in index notation. That should always be a filter imo.

I want to maintain support for slicing and selection by strings/index.

This is the status quo, so I think this can be closed.

stinodego avatar Feb 17 '24 23:02 stinodego