I would like to remove the characters from the columns in the pandas' data frame. I got around 10 columns and each has characters. Please see the sample column. Column type is a string and would like to remove the characters and convert the column int float
10.2\I
10.1\Y
NAN
12.5\T
13.3\T
9.4\J
NAN
12.2\N
NAN
11.9\U
NAN
12.4\O
NAN
8.3\U
13.5\B
NAN
13.1\V
11.0\Q
11.0\X
8.200000000000001\U
NAN
13.1\T
8.1\O
9.4\N
I would like to remove the '\', all the Alphabets and make it into a float. I don't want to change the NAN.
I used df[column name'] = df.str[:4] - It removes some of the cells but not all cells. Also, unable to convert into a float as I am getting an error
df[column name'] = df.str[:4]
df['column name'].astype(float)
0 10.2
1 10.1
2 NaN
3 12.5
4 13.3
5 9.4\
6 8.3\
22 8.1\
27 9.4\
28 NaN
29 10.6
30 10.8
31 NaN
32 7.3\
33 9.8\
34 NaN
35 12.4
36 8.1\
Still it's not converting other cells
Getting error when I tried to convert into a float
ValueError: could not convert string to float: '10.2\I'