I have a data frame that looks like this.
0 1.144921
1 1.000000
2 1.119507
3 inf
4 0.000000
5 inf
6 0.000000
7 0.000000
8 1.000000
9 0.000000
10 0.000000
11 0.000000
12 1.793687
13 inf
I am trying to get rid of the 'inf
' string. Basically, I just want to strip out all strings and keep only the numbers in the dataframe.
I tried the following code below.
kepler = re.sub("\D", "", kepler)
kepler = re.sub('[^0-9]','0', kepler)
When I run either of these lines of code I get the following error.
TypeError: expected string or bytes-like object
If I have a very simple string, it actually does work. So, this will work.
s = '83jjdmi239450 19dkd'
s = re.sub("\D", "", s)
Unfortunately, the code doesn't work on my dataframe. Any thoughts? Thanks.