python - 如何让 python 不将数据帧描述分解成块?
问题描述
下面的代码将 df 描述输出到两个块中,尽管 display.max_rows 和 display.max_columns 设置为高值。
我想打印它没有休息。有什么办法吗?
import pandas as pd
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 1000)
data = {'Age': [20, 21, 19, 18],
'Height': [120, 121, 119, 118],
'Very_very_long_variable_name': [40, 71, 49, 78]
}
df = pd.DataFrame(data)
print(df.describe().transpose())
解决方案
尝试在顶部添加此设置:
pd.set_option('display.expand_frame_repr', False)
现在:
import pandas as pd
pd.set_option('display.expand_frame_repr', False)
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 1000)
data = {'Age': [20, 21, 19, 18],
'Height': [120, 121, 119, 118],
'Very_very_long_variable_name': [40, 71, 49, 78]
}
df = pd.DataFrame(data)
print(df.describe().transpose())
输出:
count mean std min 25% 50% 75% max
Age 4.0 19.5 1.290994 18.0 18.75 19.5 20.25 21.0
Height 4.0 119.5 1.290994 118.0 118.75 119.5 120.25 121.0
Very_very_long_variable_name 4.0 59.5 17.935068 40.0 46.75 60.0 72.75 78.0
推荐阅读
- react-native - React Native - 条件渲染不起作用
- flutter - 如何返回 StatefulWidget 包含的值以在 ListView.builder 中使用它?
- c# - 多个表单提交时的 MVC 路由错误
- cypress - 如果我们从定位元素中获取 3 个元素并且我需要单击 cypress 中的第 2 个元素,如何处理
- ruby-on-rails - 如何实现“安全导航”兼容的“空对象模式”?
- asp.net-core - 如何通过 app.UseStatusCodePages 返回 404 状态码?
- ios - 如何使用 Swift 过滤器根据搜索键对嵌套数组进行过滤
- java - 我必须在哪里使用注释@Service @Transactional
- javascript - 看不懂问题
- json - 从 JSON 响应中检索值