Can I have a custom function for fill na in Pandas?
s.fillna(lambda r: r["SomeColumn"]**2)
I'd love to have a custom function that could take in the entire row itself.
Can I have a custom function for fill na in Pandas?
s.fillna(lambda r: r["SomeColumn"]**2)
I'd love to have a custom function that could take in the entire row itself.
The value
argument can be a Series or DataFrame. So you could calculate the correct value ahead of time, and pass that to .fillna
fill_value = s['SomeColumn'] ** 2
s.fillna(fill_value)