If I have a dataframe and want to drop any rows where the value in one column is not an integer how would I do this?
The alternative is to drop rows if value is not within a range 0-2 but since I am not sure how to do either of them I was hoping someonelse might.
Here is what I tried but it didn't work not sure why:
df = df[(df['entrytype'] != 0) | (df['entrytype'] !=1) | (df['entrytype'] != 2)].all(1)
df = df[(df['entrytype'] != 0) | (df['entrytype'] !=1) | (df['entrytype'] != 2)].all(1)however, if you have any rows in a column that is not numeric then the dtype willobjectcould you not just test thisdf[~df['entrytype'].isin([0,1,2])]this willl filter the rows that are not 0, 1 or 2 if you are expecting the values to only be those valuesdf['entrytype'].apply(lambda x: str(x).isdigit())