我使用python3。在
这是我的数据结构:
^{1}$我已经成功地创建了一个表,显示从第一个嵌套字典(以'Vendor'
开头)的键创建的列。行名是'HexaPlex x50'
。其中一列包含带有数字的计算机,即嵌套字典:
我希望能够在列'Computers'
下的单元格中的表中拥有键值对,实际上是一个嵌套表。在
ATM看起来像这样:
桌子应该看起来像这样
我怎样才能做到这一点?在
此外,我想给数字或者比最新版本的BIOS版本更低的单元上色。在
我还面临这样一个问题:在一个例子中,包含计算机的字典非常大,以至于即使我设置了pd.set_option('display.max_colwidth', -1)
,它也会被缩写。看起来是这样的:
正如评论中已经强调的,pandas不支持“子数据帧”。为了KISS,我建议复制这些行(或者管理两个单独的表。。。如有必要)。在
您提到的问题(parsing a dictionary in a pandas dataframe cell into new row cells (new columns))中的答案将为每个计算机名生成新的(帧宽)列。考虑到您的域模型,我怀疑这是否是您的目标。在
pandas的缩写可以通过使用另一个输出引擎来避免,例如tabulate(Pretty Printing a pandas dataframe):
您还可以使用一些
^{pr2}$groupBy(..).apply(..)
+string magic来生成一个字符串表示,它只隐藏重复项:样式化的输出可以通过新的Styling API生成,它仍然是临时的并且正在开发中:
同样,您可以使用一些逻辑来“合并”列中连续的冗余值(简单的例子,我假设更多的努力可以得到更好的输出):
以上示例的代码
相关问题 更多 >
编程相关推荐