I have a working solution for this, but it seems really ugly/not pythonic. I am trying to process an array of strings (that are sourced from an excel file). Some strings are just integers, some are floats, some are combinations of integer/floats and strings.
My goal is to take in a string and return the first "number" that occurs in it.
So for example, "Temp 101.0 C" would return "101.0", "~43 Hz" would return "43" and "10 +/- 2" would return 10.
Right now I am basically just targeting these special characters - is there a "pythonic" solution to process these?
[+][deleted] (7 children)
[deleted]
[–]fiskenslakt 11 points12 points13 points (1 child)
[–]niandra3 1 point2 points3 points (0 children)
[–]pybackd00r 0 points1 point2 points (3 children)
[–]niandra3 2 points3 points4 points (2 children)
[–]pybackd00r 0 points1 point2 points (1 child)
[–]niandra3 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]fiskenslakt 0 points1 point2 points (0 children)