Try to search your question here, if you can't find : Ask Any Question Now ?

Replacing all "?" with "NaN" in all columns

HomeCategory: stackoverflowReplacing all "?" with "NaN" in all columns
willson asked 2 weeks ago

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] = [i].replace(x,y)

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!

1 Answers
Best Answer
naveen answered 2 weeks ago
Your Answer

0 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By :