seb2704
seb2704

Reputation: 540

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

I'm trying to get the column of a Dataframe as Series.

df['a']

returns allways a pl.Dataframe. Right now I'm doing it this way

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

I don't think that's the best way to do it. Does anyone have an idea?

Upvotes: 5

Views: 4134

Answers (1)

ritchie46
ritchie46

Reputation: 14710

I don't really understand. This snippet runs, so it returns a pl.Series.

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

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

Upvotes: 8

Related Questions