I would like to calculate the standard deviation of dataframe row for the columns 'foo' and 'bar'.
I am able to find min,max and mean but not std.
import polars as pl
df = pl.DataFrame(
{
"foo": [1, 2, 3],
"bar": [6, 7, 8],
"ham": ["a", "b", "c"],
}
)
#finding the sum works for me, the same code works for min and max as well.
df = df.select(pl.col('*'),\
df.select(pl.col(['foo','bar']))\
.sum(axis=1)\
.apply(lambda x:round(x,2))\
.alias('sum'))
however, the below code throws an error when trying to calculate the standard deviation as the std function does not have axis argument available.
df = df.select(pl.col('*'),\
df.select(pl.col(['foo','bar']))\
.std(axis=1)\
.apply(lambda x:round(x,2))\
.alias('std'))
Is there any better method available to compute standard deviation in such scenario ?