I need to drop rows in a dataframe created using panda in Python. I've tried all the different ways mentioned in different forums but nothing seems to work.
I want to delete the rows with ZipCodes more than 5 digits long, so I saw this as an answer:
df = df[len(df.CoulmnName) <5]
df.head
and I get Error: "KeyError: False" And I want to iterate through the dataframe to delete rows where there are values greater than 1 in different columns. This is what I tried:
for x in cleandata4bestdeal.columns:
if x[line] > 1:
df.drop(df[line])
and it doesn't work. I want to iterate through the column headers to remove the rows with values that are not 1's or 0's.