栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

熊猫:如何引用和打印多个数据框为HTML表格

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

熊猫:如何引用和打印多个数据框为HTML表格

正如Thomas K指出的那样,您可以用来

IPython.core.display.display
在IPython笔记本中合并Dataframe的显示和打印语句:

import pandas as pdfrom IPython.core import display as ICDdf = pd.Dataframe(    {'area': [5, 42, 20, 20, 43, 78, 89, 30, 46, 78],     'cost': [52300, 52000, 25000, 61600, 43000, 23400, 52300, 62000, 62000, 73000],      'grade': [1, 3, 2, 1, 2, 2, 2, 4, 1, 2], 'size': [1045, 957, 1099, 1400, 1592, 1006, 987, 849, 973, 1005],      'team': ['man utd', 'chelsea', 'arsenal', 'man utd', 'man utd', 'arsenal', 'man utd', 'chelsea', 'arsenal', 'arsenal']})result =  df.groupby(['team', 'grade']).agg({'cost':'mean', 'area':'mean', 'size':'sum'}).rename(columns={'cost':'mean_cost', 'area':'mean_area'})dfs = {team:grp.drop('team', axis=1)        for team, grp in result.reset_index().groupby('team')}for team, grp in dfs.items():    print(team)    ICD.display(grp)

产生



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/614244.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号