简体   繁体   中英

fill Nan based on range of values in a column

I have some data in a column read from a csv file using pandas. It consists of values ranging between -1 enter image description here 1520 to +2000. I want to fill Nan, if the value is less than +550 and greater than +1800. How can I do This.

try this

df.replace(df.loc[(df['Sensor_data(N)']<550) or (df['Sensor_data(N)']>1800)],'NaN',inplace=True)

feel free to ask if any doubt

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