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

相关推荐
FriendshipT几秒前
Ultralytics:解读 YOLO26 知识蒸馏
人工智能·pytorch·python·深度学习·yolo
蓝田~3 分钟前
AI Demo到上线有多远?→ 安全纵深防御+Token成本精确计算+可观测性,PrismAI三周工程化复盘
人工智能·安全
东坡肘子8 分钟前
Apple Intelligence 已通过审核,即将在中国提供服务 -- 肘子的 Swift 周报 #148
人工智能·swiftui·swift
weixin_431600449 分钟前
前端对接 SSE 的两种常见方式
前端·后端·学习·ai·sse·nest.js
BUG研究员_9 分钟前
工具绑定与调用
python·agent
苏灿烤鱼10 分钟前
AI Agent 深拆 | 图能让 AI 决策可追责吗?Semantica 登顶拆解
python·github·agent
watersink11 分钟前
机器学习FM、FFM
人工智能·机器学习
九硕智慧建筑一体化厂家16 分钟前
从光伏板到护眼灯,直流照明如何重构绿色校园的能源基因
运维·人工智能·重构·智慧城市·能源
user-猴子1 小时前
2026国产AI智能体七强横评:WorkBuddy、AiPy、悟空、Kimi Work、TRAE Work、QoderWork、百度搭子怎么选?
人工智能·百度·dubbo
Sirius.z8 小时前
第R6周:LSTM实现糖尿病探索与预测
python