python - 无法使用 df.head(5) 打印前 5 行
问题描述
在这里完成菜鸟。我一直在尝试按照以下说明访问 Kaggle 上的数据集并读取前 5 行。
https://towardsdatascience.com/simple-and-multiple-linear-regression-with-python-c9ab422ec29c
我正在使用 spyder,当我运行以下代码时,我只在控制台中获得了一个运行文件 wdir= 注释
以下是代码:
import pandas as pd
df=pd.read_csv('weight-height.csv')
df.head(5)
输出: 代码和控制台输出
解决方案
中篇文章可能正在使用jupyter 笔记本,它将占用最后一行并将其作为格式化输出放在其下方的单元格中,而没有print
. 在常规的 python 脚本/空闲或其他 IDE 中,您需要实际使用该print
功能打印到终端/控制台。
import pandas as pd
df = pd.read_csv('weight-height.csv')
print(df.head(5))
推荐阅读
- javascript - 运行赛普拉斯时无法从构造函数中检索对象
- amazon-web-services - 带有外部 rabbitmq 代理的 aws
- google-drive-api - 谷歌驱动器文件访问需要什么 client_secret.json 文件
- javascript - 无法访问对象函数内的对象键?
- java - 尝试在导致崩溃的空对象引用上调用虚拟方法
- html - 为什么我的网站突然打不开了?
- python - 将包含 unicode 数据的 bytearray 转换为 str
- javascript - 如何理解这个 JavaScript 函数的流程
- excel - 如何从单元格中的字符串中识别和删除单个字母?
- react-native - 我怎样才能随时待命?