pythonbook/实力学习pygwalker/1.py

14 lines
359 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pandas as pd
# 假设这个库和函数存在用于处理DataFrame
import pygwalker as pyg
# 加载数据并处理
df = pd.read_csv('./titanic.csv')
walker = pyg.walk(df)
# 调用to_html()获取HTML字符串
walker_html = walker.to_html()
# 将HTML字符串写入到文件
with open("1.html", "w", encoding="utf-8") as f:
f.write(walker_html)