Python pandas_profiling 数据预览,生成html报告

190 阅读1分钟
  •        Python : 3.8.8
  •          OS : Windows 21H1
  •       Conda : 4.12.0
  •     PyCharm : 2022.1 (Community Edition)

代码

import pandas as pd
import pandas_profiling

df = pd.read_csv("titanic.csv")
profile = pandas_profiling.ProfileReport(df,title="titanic",explorative=True)
profile.to_file("result.html")

结果

D:\Develop\Anaconda3\python.exe C:/Users/admin/Desktop/pythonProject/main.py
Summarize dataset: 100%|██████████| 37/37 [00:04<00:00,  8.99it/s, Completed]
Generate report structure: 100%|██████████| 1/1 [00:02<00:00,  2.79s/it]
Render HTML: 100%|██████████| 1/1 [00:01<00:00,  1.02s/it]
Export report to file: 100%|██████████| 1/1 [00:00<00:00, 143.37it/s]

Process finished with exit code 0

pd-pandas_profiling-1.png

pd-pandas_profiling-2.png

学习推荐


Python具有开源、跨平台、解释型和交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。