How to convert polars series to pandas series in python?

Viewed 510

How to convert polars series to pandas series in python?

My current workaround is:

df = pl.DataFrame({"a":[1,1,2], "b":[2,2,3], "c":[1,2,3]})
df[["a"]].to_pandas()["a"]

But is there a way to do it directly from polars series to pandas series?

Why I need this is because I feed the data into statmodels.OLS and want to have variable names instead of numbers for variables. And when I feed the data into statmodels.OLS directly from polars I get the following error:

unrecognized data structures: <class 'polars.internals.series.Series'> / <class 'polars.internals.frame.DataFrame'>
1 Answers

For polars>=0.13.9

pl.Series([1, 2, 3]).to_pandas()

For polars<=0.13.8

pl.Series([1, 2, 3]).to_arrow().to_pandas()
Related