def udf(row):
print(row)
print(row[0])
print(row[1])
return row
df = pl.DataFrame({'a': [1], 'b': [2]})
df = df.map_rows(udf)
gives output,
(1, 2)
1
2
but I would like to use the []
notation, is there a specific reason that it comes as a tuple by default as when I use,
def udf(row):
print(row['a'])
print(row['b'])
return row
df = pl.DataFrame({'a': [1], 'b': [2]})
df = df.map_rows(udf)
I get
TypeError: tuple indices must be integers or slices, not str
how do I make the []
notation work for custom udfs?