I have a dataframe that I previously transposed. Before the transposition, the numerical column had values float64 and that was expected. However, after the transpose, the float values turned into strings. I tried to convert the dataframe using the .as_type('float') but it got raised with an exception because some columns had values like '4.32 6.50' in the same cell.
I tried using a regex but when I get it to work in only returns something like:
False False False ... False False
my dataframe looks like this:
q1 q2 q3 q4
4.22 4.11 3.89 4.11
5 2.36 3.68 4.23
1.2 4.63 4.28 5.67 4.87
There are over 1000 rows, and there are multiple problematic rows in the dataframe. I don't know what they are. Therefore, manually removing it won't be an option
I tried the following code
final = final[~final['q1'].str.contains("\d+\.\d\s\d+\.\d", na = False)]
But, the problematic row is still there.
The final result looks like this
q1 q2 q3 q4
All the rows went gone. Not all of them are problematic