Jovian
⭐️
Sign In
In [40]:
import numpy as np
import pandas as pd
In [41]:
data = pd.read_csv("Mall_Customers.csv");
In [122]:
data.head()
Out[122]:
In [123]:
#On an average, who earns more Male or female?
In [124]:
data[data["Gender"]=="Male"]["Annual Income (k$)"].mean()
Out[124]:
62.22727272727273
In [125]:
data[data["Gender"]=="Female"]["Annual Income (k$)"].mean()
Out[125]:
59.25
In [126]:
#Male
In [127]:
#On an average, who spends more male or female?
In [128]:
data[data["Gender"]=="Male"]["Spending Score (1-100)"].mean()
Out[128]:
48.51136363636363
In [129]:
data[data["Gender"]=="Female"]["Spending Score (1-100)"].mean()
Out[129]:
51.526785714285715
In [130]:
#Female
In [131]:
#our dataset consists of how many males or females?
In [132]:
data[data["Gender"]=="Male"].count()
Out[132]:
CustomerID                88
Gender                    88
Age                       88
Annual Income (k$)        88
Spending Score (1-100)    88
dtype: int64
In [133]:
data[data["Gender"]=="Female"].count()
Out[133]:
CustomerID                112
Gender                    112
Age                       112
Annual Income (k$)        112
Spending Score (1-100)    112
dtype: int64
In [134]:
data["Gender"].count()
Out[134]:
200
In [135]:
#Person with 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[135]:
11    Female
Name: Gender, dtype: object
In [139]:
#What is the average age of male and female
In [140]:
data[data["Gender"]=="Male"]["Age"].mean()
Out[140]:
39.80681818181818
In [141]:
data[data["Gender"]=="Female"]["Age"].mean()
Out[141]:
38.098214285714285
In [149]:
#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()
len(data[(data["Annual Income (k$)"]<average_annual_income) & (data["Spending Score (1-100)"]>average_spend)])
Out[149]:
49
In [150]:
#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[150]:
48
In [152]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: