简体   繁体   中英

How to change Nan values to zero in a list of DataFrame in Python 3.7

I want to change the Nan values in a specific column in a list of DataFrame. I have applied methods (below). I am not unable to change the nan to zero. Is there any way to replace the values to zero Data is the list of DataFrame and qobs is the specific column in each DataFrame

for value in data:
    value['qobs']= value['qobs'].replace(np.nan,0)

for value in data:
    value['qobs']= value['qobs'].fillna(0)

You can change column like this:

data['qobs'] = data['qobs'].fillna(0)
print(data)

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