5-AM Project: day8 Practical data science with Python 4

Chapter 5 Exploratory Data Analysis and Visualization

  • EDA and visualization libraries in Python
  • Performing EDA with Seaborn and pandas
  • Using EDA Python packages
  • Using visualization best practices
  • Making plots with Plotly

Performing EDA with Seaborn and pandas

Making boxplots and letter-value plots

python 复制代码
import matplotlib.pyplot as plt
df['Minutes'].plot.box()
plt.show()

f = plt.figure(figsize=(5.5, 5.5))  # this changes the size of the image -- more on this is chapter 5
f.patch.set_facecolor('w')  # sets background color behind axis labels
df['Minutes'].plot.box()
plt.tight_layout()  # auto-adjust margins

Making histograms and violin plots

python 复制代码
sns.histplot(x=df['Minutes'], kde=True)

Let's look at a few groups of data at once with a violin plot. Let's first select the top five genres by number of songs and create a separate DataFrame with only this data:

python 复制代码
top_5_genres = df['Genre'].value_counts().index[:5]
top_5_data = data=df[df['Genre'].isin(top_5_genres)]

Making scatter plots with Matplotlib and Seaborn

python 复制代码
plt.scatter(df['Minutes'], df['MB'])

Examining correlations and making correlograms

python 复制代码
sns.pairplot(data=df)

Making missing value plots

python 复制代码
import missingno as msno
msno.matrix(df)

This shows a matrix of non-missing values in gray and missing values in white. Each row is a line across each column. From this, we see that the Composer column has several missing values, but none of the other columns are missing any values. The spark line on the right side shows the total missing values across all columns for each row and shows the maximum and minimum number of complete values for the rows. In our case, 7 means the minimum number of non-missing values in a row is 7, and the maximum number of non-missing values in a row is 8.

Using EDA Python packages

python 复制代码
from pandas_profiling import ProfileReport

report = ProfileReport(df)

report

Using visualization best practices

Saving plots for sharing and reports

相关推荐
硅谷秋水10 分钟前
基于仿真的感知类人运动:苹果HALO 方法
人工智能·机器学习·计算机视觉·语言模型·机器人
小飞在努力12 分钟前
【实现负载均匀在线判题⑤】MVC 架构搭建与 Model 题目数据模块实现
c语言·开发语言·c++·笔记·后端
撸码猿14 分钟前
数据采集场景的语序点选验证码:90.2% 整词准确率的本地 OCR 实践
python·ocr
用户8425581308716 分钟前
同一件事,两行日志差八小时
人工智能
敢敢のwings21 分钟前
使用FACT给机器人补上“手感“
人工智能·机器人
用户03321266636732 分钟前
使用 Python 在 Excel 中创建折线图和条形图
python·excel
电科_银尘1 小时前
【大模型算法与工程 32】全量微调与参数高效微调:如何选择
人工智能·算法·机器学习
深海鱼肝油ya1 小时前
Agent工具系统——Tool Calling & Schema
人工智能·大模型·agent·schema·智能体·工具调用·toolcalling
雨中飘荡的记忆1 小时前
一个人、两个 AI,我做出了一张可以点亮的中国美食地图
人工智能·后端
邂逅and回眸2 小时前
TinyML 入门:KB 级内存里怎么跑神经网络
人工智能·深度学习·神经网络