enter image description here In excel file i can do countif funtion like attached picture but How can i do this countif function in Python Pandas,please help me by providing the code
enter image description here In excel file i can do countif funtion like attached picture but How can i do this countif function in Python Pandas,please help me by providing the code
Here is an example of how you can create a function to accomplish what you are looking for. The problem with the other stackoverflow posts suggested is you would have to reshape your data for those methods to work (which you could do with df.T), but that might not be practical in your situation.
I have updated my answer to account for the first column (name).
import pandas as pd# creating example df
df = pd.DataFrame({'name':['Akbar','Jashim'],'col1':[4,5],'col2':[5,8],'col3':[2,12],'col4':[10,14],'col5':[22,16],'col6':[12,19],'col7':[3,6],})# create function to get number of values
# over 10 for each row in the df
def countif(df):over_10 = []# Loop over rows in df using .ilocfor i in df.index:row_count = (df.iloc[i,1:] > 10).sum()over_10.append(row_count)return over_10df['over_10'] = countif(df)