无法将 csv 文件导入 jupyter notebook
Couldn't import a csv file into jupyter notebook
我在 python 3 中使用 anaconda 环境的 Jupyter notebook。
我尝试从网上卷曲数据并尝试导入,但找不到文件。
代码:
!curl -0 https://raw.githubusercontent.com/jakevdp/data-USstates/master/state-population.csv
pop = pd.read_csv('state-population.csv')
错误:
FileNotFoundError: [Errno 2] File b'state-population.csv' does not
exist: b'state-population.csv'
注意:Curl 工作正常。
state/region,ages,year,population
AL,under18,2012,1117489
AL,total,2012,4817528
AL,under18,2010,1130966
...
...
...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 57935 100 57935 0 0 129k 0 --:--:-- --:--:-- --:--:-- 129k
尝试给出文件的完整路径。
看来您有疑问的问题与 curl 相关,而不是将 csv 加载到 Jupyter 中。如果您在标题中指定 curl,您可能会得到更多帮助。
确保在 curl 保存获取的 csv 文件的同一文件夹中打开 Jupyter .ipynb 文件。或者将路径的完整地址传给pd.read_csv函数
我的朋友,
您需要先使用此命令下载数据集,
!wget "http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data"
import numpy as np
import pandas as pd
# reading the .data file using pandas
df = pd.read_csv('./auto-mpg.data', names=cols, na_values = "?",
comment = '\t',
sep= " ",
skipinitialspace=True)
#making a copy of the dataframe
data = df.copy()
如果对你有用就点个赞,如果不行就给点意见
我确实找到了替代解决方案,
我 git 将所有 .csv 文件克隆到包含 .ipynb 的文件夹并尝试导入 .csv 文件,成功了!
我在 python 3 中使用 anaconda 环境的 Jupyter notebook。 我尝试从网上卷曲数据并尝试导入,但找不到文件。
代码:
!curl -0 https://raw.githubusercontent.com/jakevdp/data-USstates/master/state-population.csv
pop = pd.read_csv('state-population.csv')
错误:
FileNotFoundError: [Errno 2] File b'state-population.csv' does not exist: b'state-population.csv'
注意:Curl 工作正常。
state/region,ages,year,population
AL,under18,2012,1117489
AL,total,2012,4817528
AL,under18,2010,1130966
...
...
...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 57935 100 57935 0 0 129k 0 --:--:-- --:--:-- --:--:-- 129k
尝试给出文件的完整路径。
看来您有疑问的问题与 curl 相关,而不是将 csv 加载到 Jupyter 中。如果您在标题中指定 curl,您可能会得到更多帮助。
确保在 curl 保存获取的 csv 文件的同一文件夹中打开 Jupyter .ipynb 文件。或者将路径的完整地址传给pd.read_csv函数
我的朋友,
您需要先使用此命令下载数据集,
!wget "http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data"
import numpy as np
import pandas as pd
# reading the .data file using pandas
df = pd.read_csv('./auto-mpg.data', names=cols, na_values = "?",
comment = '\t',
sep= " ",
skipinitialspace=True)
#making a copy of the dataframe
data = df.copy()
如果对你有用就点个赞,如果不行就给点意见
我确实找到了替代解决方案, 我 git 将所有 .csv 文件克隆到包含 .ipynb 的文件夹并尝试导入 .csv 文件,成功了!