1

I'm trying to replace all of the "?" in my dataframe with "NaN" values. I have tried doing this:

for i in list(df):
    lst = list(df.i)
    for y in lst:
        if y == "?":
            x = y.replace("?", "NaN")
    df[i] = df[i].replace(x,y)
df

It spits out an error saying dataframe has not attribute "i". i is each column in the data frame, lst is a list of each row in every column. y is every object in lst. Is there a way to bypass so that I can get lst = list(df.columnName) for every column? Thank you!

Keegan Husom
  • 139
  • 1
  • 8

0 Answers0