Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mask and then fillnan#

a b c 
1 1 5.0
1 1 None
1 1 4.0
1 2 1.0
2 1 2.0
2 1 None

mask = (df['a']==1) & (df['b']==1)
mean = df.loc[mask, 'c'].mean()
df.loc[mask, 'c'] = df.loc[mask, 'c'].fillna(mean)
Comment

PREVIOUS NEXT
Code Example
Python :: qlcdnumber set value python 
Python :: get the factorial of a number on python 
Python :: vitalik buterin age 
Python :: por que usar np.log 
Python :: how to write a python script to find the value of x at a given y value 
Python :: convert python to c++ online 
Python :: python sort list of tuples lexicographically 
Python :: connect kaggle to colab 
Python :: matplotlib text relative to axis 
Python :: problem with console writeline python 
Python :: download viper for python ubutunu 
Python :: Fish market linear regression implementattion 
Python :: undefined variable in python 
Python :: c++ code to python code converter online 
Python :: autoscrapper installation 
Python :: Python colorbar for circular heatmap 
Python :: pandas join tables based on column of different length 
Python :: pycaw , Python Audio Control Lib 
Python :: pandas difference between subsequent lines 
Python :: what optimizer to simplernn 
Python :: python last letter of string 
Python :: to find keywords in a text spacy 
Python :: loess dataframe 
Python :: currelation matrix python 
Python :: python type hint array of objects 
Python :: pandas column rgeex doesnot contain 
Python :: python interface kenee 
Python :: Python multiline comment using docstrings 
Python :: striding in python 
Python :: online python debugger 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =