python - 如何在 Google Colab 中查看完整的行
问题描述
我正在使用 Google Colab python 3.x,并且我有一个如下的数据框。我想查看每一行和每一列的所有单元格。我怎样才能做到这一点?我试过pd.set_option('display.max_columns', 3000)
了,但没有用。
# importing pandas as pd
import pandas as pd
# dictionary of lists
dict = {'name':["a1", "b2", "c2", "d3"],
'degree': ["We explained to customer how correct fees (100) were charged. Account balance was too low", "customer was late in paying fees and we have to charge fine", "customer's credit score was too low and we have to charge higher interest rate", "customer complained a lot and didnt listen to our explanation. I had to escalate the call"],
'score':[90, 40, 80, 98]}
# creating a dataframe from a dictionary
df = pd.DataFrame(dict)
print (df)
name degree score
0 a1 We explained to customer how correct fees (100... 90
1 b2 customer was late in paying fees and we have t... 40
2 c2 customer's credit score was too low and we hav... 80
3 d3 customer complained a lot and didnt listen to ... 98
解决方案
用于pd.set_option('max_colwidth', <width>)
列宽和pd.set_option('max_rows', <rows>)
行数。
见https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html
[] pd.set_option('max_rows', 99999)
[] pd.set_option('max_colwidth', 400)
[] pd.describe_option('max_colwidth')
display.max_colwidth : int
The maximum width in characters of a column in the repr of
a pandas data structure. When the column overflows, a "..."
placeholder is embedded in the output.
[default: 50] [currently: 400]
[] df = pd.DataFrame(d)
[] df
name degree score
0 a1 We explained to customer how correct fees (100) were charged. Account balance was too low 90
1 b2 customer was late in paying fees and we have to charge fine 40
2 c2 customer's credit score was too low and we have to charge higher interest rate 80
3 d3 customer complained a lot and didnt listen to our explanation. I had to escalate the call 98
推荐阅读
- regex - 在 Lua/PCRE/OpenResty 中使用正则表达式检测所有表情符号
- azure - 由于擦除,Blazor HttpClient GetAsync 超级慢
- cakephp - 如何在 cakephp 3.6 中同时向多个表中插入数据
- matlab - 在 ode MATLAB 求解器上使用中间值
- python - TensorFlow 2.0 dataset.__iter__() 仅在启用急切执行时受支持
- ios - iOS 启动屏幕忽略智能反转
- javascript - NodeJS:util.inspect对象,里面有函数
- php - 如何使用 PHP 将数字格式化为塞尔维亚语格式?
- sql - 参数返回 0 而不是 475 的 SQL 查询
- javascript - DropZone 实现不起作用,未捕获类型错误:$(...).dropzone 不是函数