在 polars 中将列作为 pl.Series 而不是 pl.Dataframe

Get column as pl.Series not as pl.Dataframe in polars

我正在尝试将 Dataframe 的列作为系列。

df['a']

returns 总是 pl.Dataframe。 我现在就是这样做的

pl.Series('GID_1',df['GID_1'].to_numpy().flatten().tolist())

我认为这不是最好的方法。有人有想法吗?

我不是很懂。此代码段运行,因此它 returns a pl.Series.

df = pl.DataFrame({
    "A": [1, 2, 3],
    "B": [1, 2, 3]
})

assert isinstance(df["A"], pl.Series)