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

相关推荐
cute_ming36 分钟前
LangGraph入门:LCEL详解
人工智能·机器学习·transformer·知识图谱
草莓熊Lotso2 小时前
Qt 进阶核心:UI 开发 + 项目解析 + 内存管理实战(从 Hello World 到对象树)
运维·开发语言·c++·人工智能·qt·ui·智能手机
Light606 小时前
智链全球,韧性履约:AI赋能新一代海外EPC/EPCM项目管理解决方案
人工智能·数字孪生·风险管理·ai赋能·海外epc/epcm·智慧项目管理·协同增效
嗯嗯=6 小时前
python学习篇
开发语言·python·学习
WoY20206 小时前
opencv-python在ubuntu系统中缺少依赖
python·opencv·ubuntu
棒棒的皮皮8 小时前
【深度学习】YOLO核心原理介绍
人工智能·深度学习·yolo·计算机视觉
大游小游之老游8 小时前
Python中如何实现一个程序运行时,调用另一文件中的函数
python
2501_941804328 小时前
从单机消息队列到分布式高可用消息中间件体系落地的互联网系统工程实践随笔与多语言语法思考
人工智能·memcached
mantch8 小时前
个人 LLM 接口服务项目:一个简洁的 AI 入口
人工智能·python·llm
weixin_445054728 小时前
力扣热题51
c++·python·算法·leetcode