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

相关推荐
小哈里3 分钟前
【Agent】从Prompt工程、Context工程到 Harness工程,让 AI 能真正完成工作
人工智能·prompt·agent·ai编程·harness
Juicedata19 分钟前
从 Meta 的工程实践看 EB 级 AI 存储架构
人工智能·架构
小弥儿22 分钟前
38K星的开源项目 t3code:给 Claude Code 和 Codex 装一个手机遥控器
学习·智能手机·开源·github
CCblandy32 分钟前
缓存淘汰实测:一次全表扫描把 LRU 命中率从 46% 打到 38%,W-TinyLFU 守住 50% 却贵 11 倍
后端·python·缓存·性能优化·架构
土星云SaturnCloud38 分钟前
基于边缘计算与AI视觉的智慧街面治理方案:架构设计与场景落地
服务器·人工智能·ai·边缘计算
汤米粥40 分钟前
cmd手动创建的Django项目怎么用社区版Pycharm运行起来
python·pycharm·django
武子康42 分钟前
DOA 100%、GSC 改善 12 dB,ESP32-P4 远场拾音就能用了吗?
人工智能·后端·agent
tianxuanjg42 分钟前
无人机科研轻量化结构件采购指南|高校实验室选型避坑:轻量化与结构强度如何兼顾
人工智能·经验分享·机器人·无人机·制造
Python大数据分析@44 分钟前
DeepSeek Harnees实用的3个插件导航
人工智能
涵玥1 小时前
python题目练习12-小玉家的电费//小玉在游泳//小鱼的航程
python·python每日一练·洛谷题目