Convert Text to Numbers
Convert values into a Python list of numbers using Pandas. Inputs are decimal numeric strings, invalid text, empty strings or None. Numeric strings may contain surrounding whitespace or a minus sign. Replace invalid or missing values with 0. All valid numbers are finite. Keep order; empty input returns an empty list.
Difficulty: beginner
Show hint
Use pd.to_numeric on a Series with errors="coerce", fill missing results with 0, and call tolist(). Set dtype="object" when creating an empty-capable Series.
Examples
[["12","bad","2.5",null]][12,0,2.5,0]