简体   繁体   中英

How to replace values in Dataframe based on multiple conditions?

I have one large dataframe that currently has both "?", "??", and NaN values that I'm trying to remove. I want to redefine the columns to be booleans to see whether they contained "?", "??" or NaN.

My current approach involves cloning different columns of the dataframe based on whether they contain just "?", just "??" or just NaN values and separately iterating through the columns, col, to change the values (ex: df[col] = df[col].isnull()) and finally merging them together again.

Is there an easier way to do this?

how about using quick-sort algorithm. And, I am not sure I got what your data looks like and what results you want to obtain. Maybe you could show us parts of your data frame.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM