python - 在 colab 中找到 pd.head() 的选项

标签 python pandas

我正在做 colab,我发现了一些奇怪的东西,请看这个: pd.head() head

但我想这样做: enter image description here

这个问题有什么解决办法吗? 谢谢!

最佳答案

除非您使用 print 打印数据框,否则 google colab 会自动以表格格式显示数据。如果在某些情况下没有,您可以使用 display 强制它显示

您可以使用display形式ipython打印多个表格。

from IPython.display import HTML, display
display(df1)
display(df2)

enter image description here

您还可以使用 google.colab.data_table 扩展程序来显示具有更多功能的表格。

%load_ext google.colab.data_table
from IPython.display import HTML, display
display(df1)
display(df2)

enter image description here

关于python - 在 colab 中找到 pd.head() 的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63931616/

相关文章:

Python PyQt 进度条忙

python - 如何在文件中以表格形式写入数据

python - Tkinter 如何绑定(bind)到 shift+tab

python - 如何找到数组中值的负虚部然后将其变为正值?

python - NaN 值的序数编码器问题

具有多个条件和计算的 Pandas 数据框

python - 在所有 Pandas DataFrame 列中搜索字符串并过滤

php - 执行 SQL 查询时执行脚本

python - 迭代 sqlalchemy 的查询结果

pandas - 更改列表中列中的值