In pandas when I am using df.apply(someFun,axis=1)
which goes to a function in which a list of zipped values i.e. list(zip(val1,val2))
is being returned.
And then df.explode()
is used.
But in polars
when using
df.with_columns((pl.Series(list(someFun(x)) for x in df.iter_rows(named=True)).alias(column1)))
.
It is creating a hexadecimal values in Column1
.
using pandas:
self.var1 = 'A'
self.var2 = 'B'
def someFun(row):
var = self.var1
var2 = self.var2
cal1 = row[var] + row[var2]
cal2 = row[var] * row[var2]
return list(zip(cal1 , cal2))
df["column1"] = df.apply(someFun,axis=1)
exploded_df = df.explode("column1",ignore_index=True)
in polars dataframe value in column1 is like b"\x00O\, and explode is throwing error on this column.
tried converting the hexadecimal value to list but can't update it back in the dataframe so that explode function can work.