gpt4 book ai didi

python - 如何在 Google Colab 中查看完整的行

转载 作者:行者123 更新时间:2023-12-03 22:57:17 27 4
gpt4 key购买 nike

我正在使用 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

关于python - 如何在 Google Colab 中查看完整的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60013721/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com