Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫头功能的输出不显示_Python_Pandas_Head - Fatal编程技术网

Python 熊猫头功能的输出不显示

Python 熊猫头功能的输出不显示,python,pandas,head,Python,Pandas,Head,我正在做一个pandas培训,在第二个实验室,我应该打开一个文件并打印前5行。问题是,从下面的代码中,我只打印了“Done”,但它没有打印df.head()的输出。我找不到原因。有什么建议吗 import pandas as pd filename="https://archive.ics.uci.edu/ml/machine-learning- databases/autos/imports-85.data" hs = ["symboling","normalized-losses","

我正在做一个
pandas
培训,在第二个实验室,我应该打开一个文件并打印前5行。问题是,从下面的代码中,我只打印了“Done”,但它没有打印
df.head()
的输出。我找不到原因。有什么建议吗

import pandas as pd

filename="https://archive.ics.uci.edu/ml/machine-learning- 
databases/autos/imports-85.data"

hs = ["symboling","normalized-losses","make","fuel-type","aspiration", 
   "num-of-doors","body-style", "drive-wheels","engine-location","wheel-base", "length","width","height","curb-weight","engine-type", "num-of-cylinders", "engine-size","fuel-system","bore","stroke","compression-ratio","horsepower",
     "peak-rpm","city-mpg","highway-mpg","price"]

df = pd.read_csv(filename, names=hs)
print("Done")
df.head()

您还必须打印df.head()


刚刚注意到代码在CLI中运行正常。问题在于执行lab2.py时。如果在jupter notebook上执行,它会将输出显示为html内容。但在IDE上,为了在控制台上显示,您需要使用print。今天遇到了这个问题。“来自SQL”的熊猫入门文档假定您正在使用笔记本。我在输出中什么也看不到,因为我只是在制作脚本。我还没用笔记本呢。
print(df.head())