I have the following DataFrame
A B C
1.0 abc 1.0
abc 1.0 abc
-1.11 abc abc
I have mixed datatypes (float
and str
). How can I drop values <= -1
in column A
.
I get an error if I do the following because of the mixed datatypes
df['A'] = (df['A'] != "abc") & (df['A'] > -1)
TypeError: '>' not supported between instances of 'str' and 'int'
How can I change my object to make abc
a str
and 1.0
a float
so I can:
(df['A'] != "abc") & (df['A'] > -1)
print(df['A'].dtype)
-> object
I would like the expected output
df =
A B C
1.0 abc 1.0
abc 1.0 abc
NaN abc abc