python Pandas Profiling 一行代码EDA 探索性数据分析


1. 探索性数据分析

数据的筛选、重组、结构化、预处理等都属于探索性数据分析的范畴,探索性数据分析是帮助数据分析师掌握数据结构的重要工具,也是奠基后续工做的成功基石。html

在数据的分析项目中,数据的收集和预处理每每占据整个项目工做量的十之八九,正式这些简单的工做决定了整个项目的成败。python


Generates profile reports from a pandas DataFrame. The pandas df.describe() function is great but a little basic for serious exploratory data analysis. pandas_profiling extends the pandas DataFrame with df.profile_report() for quick data analysis.git

For each column the following statistics - if relevant for the column type - are presented in an interactive HTML report:github

Essentials: type, unique values, missing values
Quantile statistics like minimum value, Q1, median, Q3, maximum, range, interquartile range
Descriptive statistics like mean, mode, standard deviation, sum, median absolute deviation, coefficient of variation, kurtosis, skewness
Most frequent values
Histogram
Correlations highlighting of highly correlated variables, Spearman, Pearson and Kendall matrices
Missing values matrix, count, heatmap and dendrogram of missing valuesweb

官网:https://github.com/pandas-profiling/pandas-profiling数据结构


2.代码样例

一个完整的样例:
https://nbviewer.jupyter.org/github/lksfr/TowardsDataScience/blob/master/pandas-profiling.ipynbsvg

# importing required packages
import pandas as pd
import pandas_profiling
import numpy as np


# importing the data
df = pd.read_csv('/Users/lukas/Downloads/titanic/train.csv')

profile = pandas_profiling.ProfileReport(tijian_pdf)
profile.to_file("output_tijian_chinese.html")

3.效果

样例连接:https://pandas-profiling.github.io/pandas-profiling/examples/meteorites/meteorites_report.html
在这里插入图片描述
在使用过程当中发现,中文显示有问题,下面这块应该是调用seaborn 完成的。咱们从源码配置文件能够看到
在这里插入图片描述工具

在这里插入图片描述

4.解决pandas profile 中文显示的问题

咱们找到 pandas porfile 的配置文件,在conda 的环境中:字体

路径为:ui

D:\ProgramData\Anaconda3\envs\DATABASE\Lib\site-packages\pandas_profiling\view

在这里插入图片描述

打开文件看到:

## Credits for this style go to the ggplot and seaborn packages.
##   I copied the style file to remove dependencies on the Seaborn package.
##   Check it out, it's an awesome library for plotting!

其实设置是参照seaborn ,可是pandas profile 的绘图设置是独立于seaborn 的。
因此在字体设置(篮筐处),加上一个汉语字体,其余的字体干掉,注意先后空格,ok。

在这里插入图片描述

以防万一,把字体文件在这个目录再放一份
在这里插入图片描述
打完收工!

思路参考:

以 matplotlib 为基础的库的可视化库的中文显示问题,均可以这么设置


本文同步分享在 博客“shiter”(CSDN)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。

相关文章
相关标签/搜索