python网课阿里云_Python基础入门:实例--阿里云天池

4.6Python数据处理篇之Matplotlib系列(六)---plt.hist()与plt.hist2d()直方图​www.jianshu.comSeaborn 0.9 中文文档​www.cntofu.com关于使用python seaborn库绘制violinplot小提琴图的一些小坑​www.cnblogs.com

import pandas as pd

import seaborn as sns

import matplotlib.pyplot as plt

#读取下载好的数据

df=pd.read_csv(r'C:\Users\73835\Downloads\pokemon.csv')

percent_missing=df.isnull().sum()*100/len(df)

percent_missing=df.isnull().mean() #相互等价

#构造一个dataframe

missing_value_df=pd.DataFrame({

'column_name':df.columns,

'percent_missing':percent_missing})

missing_value_df.sort_values(by='percent_missing', ascending=False).head()

df['generation'].value_counts().plot.barh()

df['generation'].value_counts().plot(kind='barh')

plt.subplots(figsize=(20, 15))

ax=plt.axes()

ax.set_title('Correlation Heatmap')

coor=df.corr()

sns.heatmap(coor)

interested=['hp', 'attack', 'defense', 'sp_attack', 'sp_defense', 'speed']

sns.pairplot(df[interested])

plt.subplots(figsize=(10,8))

ax = plt.axes()

ax.set_title("Correlation Heatmap")

corr = df[interested].corr()

sns.heatmap(corr,

xticklabels=corr.columns.values,

yticklabels=corr.columns.values,

annot=True, fmt="f",cmap="YlGnBu")

for c in interested:

df[c] = df[c].astype(float)

df = df.assign(total_stats = df[interested].sum(axis=1)) #添加新列

total_stats = df.total_stats

plt.hist(total_stats, bins=35)

df.total_stats.plot(kind='hist', bins=35)

plt.xlabel('total_stats')

plt.ylabel('Frequency')

plt.subplots(figsize=(20,12))

ax = sns.violinplot(x="type1", y="total_stats",

data=df, palette="muted")

df[(df.total_stats >= 570) & (df.is_legendary == 0)]['name'].head(10)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值