Код: Выделить всё
df = pd.DataFrame(data = ([21,123], [132,412], [23, 43]), columns = ['c1', 'c2']).set_index("c1")
out = df.loc[[23, 132]] # polars equivalent of this?
print(pl.from_pandas(out.reset_index()))
Код: Выделить всё
shape: (2, 2)
┌─────┬─────┐
│ c1 ┆ c2 │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 23 ┆ 43 │
│ 132 ┆ 412 │
└─────┴─────┘
Код: Выделить всё
df = pl.DataFrame(data = ([21,123], [132,412], [23, 43]), schema = ['c1', 'c2'], orient = 'row')
print(df.filter(pl.col("c1").is_in([23, 132])))
Код: Выделить всё
shape: (2, 2)
┌─────┬─────┐
│ c1 ┆ c2 │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 132 ┆ 412 │
│ 23 ┆ 43 │
└─────┴─────┘
Я могу использовать sort() позже да, но исходные данные, которые я использую, содержат около 30 миллионов строк, поэтому я ищу что-то максимально быстрое.
Подробнее здесь: https://stackoverflow.com/questions/753 ... -in-polars