python - 如何在 python 中使用 .format 打印出数据形状
问题描述
我正在尝试在 python 中使用 .format 打印数据框的形状
尝试使用合并.format
和.shape
命令的打印语句
df_shape = df.shape
print("The data has Rows {}, Columns {}".format(df_shape[0]))
我得到的错误
IndexError: tuple index out of range
解决方案
做这个 :
df_shape = df.shape print("The data has Rows {}, Columns {}".format(df_shape[0], df_shape[1]))
或这个:
df_shape = df.shape print("The data has Rows {}, Columns {}".format(*df_shape))
推荐阅读
- api - 使用集成的 Shopware6 身份验证
- git - 如何在构建失败的情况下拒绝 git 中的提交
- html - Spacer 不接受 CSS 中的边距
- c# - HttpWebRequest 不起作用:接收时发生意外错误
- javascript - 在表单 jquery asp.net mvc 上处理的不仅仅是输入文件
- excel - 如何在日期时间的 Excel 列中突出显示某个时间范围?
- elixir - 长生不老的竹子用法
- python - 如何从 for 循环输出创建结构(例如列表)?
- assembly - 像a2f这样的分支目标是什么
在objdump反汇编中是什么意思? - azure - AKS - 将插件 HTTP 应用程序路由与 nginx 重写规则相结合?