I'm surprised I couldn't find anything about this:
Q: How can I convert values of a column to numbers with a default value if casting fails.
I need all values to be numbers in order to perform arithmetical functions on them. The raw input data contains non-convertible values like "","**", "not available", ....
E.g.
1
2
*
4
Should become:
1
2
0
4
What I've tried:
to_numberic: Does not allow to set a default value.errors=coercewill set the value toNaN, which can not be handled arithmetically afterwards.df[COLUMN].apply (makeNumber)withdef makeNumber(value): return 0.0does apparently nothing on the string values.