银行用户数据分析

数据预处理 获取数据 !wget https://raw.githubusercontent.com/Rosefinch-Midsummer/Rosefinch-Midsummer.github.io/main/content/posts/file/bankpep.csv 读入数据并以id为索引,展示前五个数据 1 2 3 4 import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv('bankpep.csv',index_col='id') print(df.head(5)) 把字符型数据替换成数值型数据 1 2 3 4 5 6 7 8 9 10 11 12 13 seq = ['married' ,'car','save_act','current_act', 'mortgage' ,'pep'] for feature in seq: df.loc[df[feature]=='YES',feature] = 1 df.loc[df[feature]=='NO',feature] = 0 #替换性别 df.loc[df['sex']=='MALE','sex'] = 1 df.loc[df['sex']=='FEMALE','sex'] = 0 print(df[0:5]) 利用dummmies矩阵处理多个离散值的特征项如把children分成children1,children2,children3 ...

创建: 2023-05-21 | 更新: 2023-05-21 | 字数: 1857字 | 时长: 4分钟 | RM

Matplotlib-pyplot绘图基础

官网 中文官网 Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Matplotlib makes easy things easy and hard things possible. Create publication quality plots. Make interactive figures that can zoom, pan, update. Customize visual style and layout. Export to many file formats. Embed in JupyterLab and Graphical User Interfaces. Use a rich array of third-party packages built on Matplotlib. 展示离散数据 散点图 柱状图 饼图 展示连续数据 直方图 箱须图 折线图 1 2 3 import matplotlib.pyplot as plt plt.figure()#创建绘图对象 半对数图 展示数据的区域或空间分布 统计地图 曲面图 动态图 bar-chart-race dashboard

创建: 2023-05-06 | 更新: 2023-05-06 | 字数: 151字 | 时长: 1分钟 | RM