如何增加Google Colab单元格输出宽度?

huangapple go评论70阅读模式
英文:

How to increase Google Colab cell output width?

问题

我找到一个非常相似的问题,但解决方案在Google Colab上不起作用。我想更好地查看我的pandas数据框列中的文本。目前,默认宽度似乎为50%。

from IPython.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
display(HTML("<style>.output_result { max-width:100% !important; }</style>"))

作为替代,我找到了一个名为Data Tables的扩展。这可能是目前可用的最佳解决方案,但似乎只适用于表格。

from google.colab import data_table
data_table.enable_dataframe_formatter()
英文:

I found a very similar question but the solution did not work on Google colab. I would like to see better the text in my pandas dataframes columns. Right now the default width seems 50%.

from IPython.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
display(HTML("<style>.output_result { max-width:100% !important; }</style>"))

As an alternative, I found an extension called Data Tables. This may be the best solution available today for it but seems to only works for tables.

from google.colab import data_table
data_table.enable_dataframe_formatter()

答案1

得分: 3

能够在Colab中增加pandas的显示输出,使用以下代码:

import pandas as pd

pd.set_option('display.width', 180)
英文:

Was able to increase pandas display output in Colab using:

import pandas as pd

pd.set_option('display.width', 180)

huangapple
  • 本文由 发表于 2023年2月14日 04:44:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440987.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定