Jovian
⭐️
Sign In
In [7]:
import numpy as np
import pandas as pd
In [8]:
data = pd.read_csv("Mall_Customers.csv");
In [9]:
data
Out[9]:
In [1]:
#ON AN AVERAGE WHO EARNS MORE, MALE OR FEMALE?
In [4]:
#ON AN AVERAGE WHO SPENDS MORE, MALE OR FEMALE?
In [5]:
#OUR DATASET CONSISTS OF HOW MANY MEN AND WOMEN? 
In [6]:
#WHAT IS THE AVERAGE AGE OF MEN AND WOMEN? 
In [7]:
#PERSON WITH THE HIGHEST SPENDING INDEX IS MALE OR FEMALE?
In [8]:
#DO PEOPLE WITH ANNUAL INCOME HIGHER THAN THE AVERAGE SPEND MORE THAN THE AVERAGE? 
In [9]:
#HOW MANY PEOPLE BELOW THE AVERAGE ANNUAL INCOME SPEND MORE THAN THE AVERAGE? 
In [10]:
#PERSON WITH THE HIGHEST ANNUAL INCOME IS MALE OR FEMALE?
In [10]:
data
Out[10]:
In [13]:
data["Average"] = data.sum(axis = 1)/200
In [14]:
data
Out[14]:
In [22]:
#ON AN AVERAGE WHO EARNS MORE, MALE OR FEMALE?
data[data["Gender"]=="Male"]["Annual Income (k$)"].mean()
Out[22]:
62.22727272727273
In [23]:
#ON AN AVERAGE WHO EARNS MORE, MALE OR FEMALE?
data[data["Gender"]=="Female"]["Annual Income (k$)"].mean()
Out[23]:
59.25
In [24]:
#ON AN AVERAGE WHO SPENDS MORE, MALE OR FEMALE?
data[data["Gender"]=="Male"]["Spending Score (1-100)"].mean()
Out[24]:
48.51136363636363
In [25]:
#ON AN AVERAGE WHO SPENDS MORE, MALE OR FEMALE?
data[data["Gender"]=="Female"]["Spending Score (1-100)"].mean()
Out[25]:
51.526785714285715
In [41]:
#OUR DATASET CONSISTS OF HOW MANY MEN AND WOMEN? 
len(data[data["Gender"]=="Male"]["Gender"])
Out[41]:
88
In [42]:
#OUR DATASET CONSISTS OF HOW MANY MEN AND WOMEN? 
len(data[data["Gender"]=="Female"]["Gender"])
Out[42]:
112
In [39]:
#WHAT IS THE AVERAGE AGE OF MEN AND WOMEN? 
data[data["Gender"]=="Female"]["Age"].mean()
Out[39]:
38.098214285714285
In [43]:
#WHAT IS THE AVERAGE AGE OF MEN AND WOMEN? 
data[data["Gender"]=="Male"]["Age"].mean()
Out[43]:
39.80681818181818
In [51]:
#PERSON WITH THE HIGHEST SPENDING INDEX IS MALE OR FEMALE?
max_spend = data["Spending Score (1-100)"].max()
data[data["Spending Score (1-100)"]==max_spend]["Gender"]
Out[51]:
11    Female
Name: Gender, dtype: object
In [59]:
#HOW MANY PEOPLE BELOW THE AVERAGE ANNUAL INCOME SPEND MORE THAN THE AVERAGE?
average_annual_income = data["Annual Income (k$)"].mean()
average_spend = data["Spending Score (1-100)"].mean()
#average annual income
len(data[(data["Annual Income (k$)"]<average_annual_income) & (data["Spending Score (1-100)"]<average_spend)])
Out[59]:
49
In [60]:
#DO PEOPLE WITH ANNUAL INCOME HIGHER THAN THE AVERAGE SPEND MORE THAN THE AVERAGE?
len(data[(data["Annual Income (k$)"]>average_annual_income) & (data["Spending Score (1-100)"]>average_spend)])
Out[60]:
48
In [2]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: