I have a DataFrame object of dtype string. A typical row looks like below:
'\n\n Dividend Indicated Gross Yield\n \n\n 1.50%\n \n'
I am trying to extract only the numerical data from the above string. for example, my desired output should be 1.50
.
The other thing to keep in mind is that each row will have different length of numericals and some may include a negative sign too.
I have tried some recommendations involving .rstrip()
, regex
, convert_objects
but they do not work as intended. Any help appreciated.
Copyright Notice:Content Author:「Siraj S.」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30769519/extract-numerical-values-from-dataframe-string-object