# coding = utf-8
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# 针对年龄进行人群分类的函数
def classification(x):
if x >= 0 and x < 20:
return "少年"
elif x >= 20 and x < 40:
return "青年"
elif x >= 40 and x < 60:
return "中年"
elif x >= 60 and x < 80:
return "老年"
else:
return "年龄超限"
# 设置字体为SimHei显示中文
plt.rcParams['font.sans-serif'] = 'SimHei'
# 设置正常显示字符
plt.rcParams['axes.unicode_minus'] = False
plt.figure(figsize=(9,5),facecolor='white',dpi=200)
# 读取数据
db = pd.read_csv("Mall_Customers.csv",sep=",",encoding='utf-8',engine='python')
# print(db.head())