In Polars how can I display a single row from a dataframe vertically like a pandas series?
06:51 03 May 2022

I have a polars dataframe with many columns. I want to look at all the data from a single row aligned vertically so that I can see the values in many different columns without it going off the edge of the screen. How can I do this?

E.g. define a dataframe

df = pl.DataFrame({'a':[0,1],'b':[2,3]})

Print df[0] in ipython/jupyter and I get:

Output from a single row of the dataframe

But if I convert df to pandas and print df.iloc[0] I get:

Output from pandas

The latter is very handy when you've got many columns.

I've tried things like df[0].to_series(), but it only prints the first element, not the first row.

My suspicion is that there isn't a direct replacement because the pandas method relies on the series having an index. I think the polars solution will be more like making a two column dataframe where one column is the column names and the other is a value. I'm not sure if there's a method to do that though.

Thanks for any help you can offer!

python dataframe python-polars