python csv转为html,在Python中将CSV转换为HTML表格
生活随笔
收集整理的這篇文章主要介紹了
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總結
以上是生活随笔為你收集整理的python csv转为html,在Python中将CSV转换为HTML表格的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一样用英语怎么说 如何英语表达一样
- 下一篇: kkb是什么意思 kkb是啥意思