Reputation: 55
I am new to Python, kindly help me to understand and go forward in python learning. Find below the sample data:
Country Age Sal OnWork
USA 52 12345 No
UK 23 1142 Yes
MAL 25 4456 No
I would like to find the mean value in SAL column if OnWork is NO
Upvotes: 0
Views: 43
Reputation: 741
Let's Say that your data looks like the following,
{'Country': 'USA', 'Age': '52', 'Sal': '12345', 'OnWork': 'No'}
{'Country': 'UK', 'Age': '23', 'Sal': '1142', 'OnWork': 'Yes'}
{'Country': 'MAL', 'Age': '25', 'Sal': '4456', 'OnWork': 'No'}
The below code will be of help in your case:
df = your_dataframe
df[df["OnWork"]=="No"]["Sal"].mean()
Upvotes: 1