I have a Pandas Dataframe and there is a column which is of float type. But numbers with decimals don't make sense for this column. So I want to find out how many floats are in this column and after that I want to delete the whole row where I have a float in this column. An alternative could be to count the number of integers and subtract this from the number of rows overall.
example Dataset
What I have:
A | B | C |
---|---|---|
0.5 | 0.1 | 2.0 |
0.8 | 0.9 | 3.5 |
0.6 | 0.2 | 1.0 |
What I need:
First count floats or integers:
C 1 (as there is only one float in column "C" or) alternatively: C 2 (as there are two integers in column "C")
Second delete rows with floats:
A | B | C |
---|---|---|
0.5 | 0.1 | 2.0 |
0.6 | 0.2 | 1.0 |
I tried to handle this problem the same way I handled my Missing Values, but this did not work.
# Count Integers
print(Data.is_integer().sum())
# Delete rows where "C" is not an integer
Data=Data.drop(Data[Data.C.is_integer()=0].index)
Both Did not work.I am using Python in Colab btw