数据分析汇总学习

https://blog.csdn.net/weixin_39778570/article/details/81157884
<https://blog.csdn.net/weixin_39778570/article/details/81157884>
import pandas as pd import numpy as np from pandas import Series, DataFrame
import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline #
打开一个花瓣长宽数据文件 f = open('iris.csv') iris = pd.read_csv(f) iris.head() SepalLength
SepalWidth PetalLength PetalWidth Name0 5.1 3.5 1.4 0.2 Iris-setosa 1 4.9 3.0
1.4 0.2 Iris-setosa 2 4.7 3.2 1.3 0.2 Iris-setosa 3 4.6 3.1 1.5 0.2 Iris-setosa
4 5.0 3.6 1.4 0.2 Iris-setosa # 绘制的颜色字典,zip传入俩个列表 iris.Name.unique() array([
'Iris-setosa', 'Iris-versicolor', 'Iris-virginica'], dtype=object) color_map =
dict(zip(iris.Name.unique(), ['blue','green','red']))
使用matplot
for species, group in iris.groupby('Name'): plt.scatter(group['PetalLength'],
group['SepalLength'], color=color_map[species], alpha=0.3,edgecolor=None,
label=species) plt.legend(frameon=True, title='Name') plt.xlabel('PetalLength')
plt.ylabel('SepalLength')

使用Seaborn
sns.lmplot('PetalLength','SepalLength',iris,hue='Name', fit_reg=False)

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信