700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python csv转为html 在Python中将CSV转换为HTML表格

python csv转为html 在Python中将CSV转换为HTML表格

时间:2021-01-08 07:17:48

相关推荐

python csv转为html 在Python中将CSV转换为HTML表格

首先安装熊猫:

pip install pandas

然后运行:

import pandas as pd

columns = ['age', 'week', 'opp', 'ACscr', 'OPPscr', 'location']

df = pd.read_csv('Crushers.csv', names=columns)

# This you can change it to whatever you want to get

age_15 = df[df['age'] == 'U15']

# Other examples:

bye = df[df['opp'] == 'Bye']

crushed_team = df[df['ACscr'] == '0']

crushed_visitor = df[df['OPPscr'] == '0']

# Play with this

# Use the .to_html() to get your table in html

print(crushed_visitor.to_html())

你会得到什么如:

ageweekoppACscrOPPscrlocation

34U171Banyo520Home40U177Aspley620Home91U127Rochedale80Home

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。