前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python pandas profile 一行代码EDA 探索性数据分析

python pandas profile 一行代码EDA 探索性数据分析

作者头像
流川疯
发布2019-09-23 15:23:24
2.5K0
发布2019-09-23 15:23:24
举报

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/wangyaninglm/article/details/101025067

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.

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

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 values

官网:https://github.com/pandas-profiling/pandas-profiling


代码样例

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

代码语言:javascript
复制
# 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")

效果

样例链接:https://pandas-profiling.github.io/pandas-profiling/examples/meteorites/meteorites_report.html

在这里插入图片描述
在这里插入图片描述

在使用过程中发现,中文显示有问题,下面这块应该是调用seaborn 完成的。我们从源码配置文件可以看到

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

解决pandas profile 中文显示的问题

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

路径为:

代码语言:javascript
复制
D:\ProgramData\Anaconda3\envs\DATABASE\Lib\site-packages\pandas_profiling\view
在这里插入图片描述
在这里插入图片描述

打开文件看到:

代码语言:javascript
复制
## 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 为基础的库的可视化库的中文显示问题,都可以这么设置


本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年09月19日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 代码样例
  • 效果
  • 解决pandas profile 中文显示的问题
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档