我创建了一个公共github存储库,并上传了一个我想阅读的.csv文件
https://github.com/emanuelemassaro/pois/blob/master/indonesia_education.csv
这就是我在做什么
import pandas as pd
import io
import requests
url="https://raw.githubusercontent.com/emanuelemassaro/pois/indonesia_education.csv"
s=requests.get(url).content
c=pd.read_csv(io.StringIO(s.decode('utf-8')))
这是我得到的输出
c
400: Invalid request
答案 0 :(得分:2)
您的网址是无效的github请求。您忘记了分支名称。使用更正的网址,您可以使用pd.read_csv
进行简单阅读:
import pandas as pd
url = "https://raw.githubusercontent.com/emanuelemassaro/pois/master/indonesia_education.csv"
pd.read_csv(url)
答案 1 :(得分:0)
我认为您只是缺少分支机构,例如主人:
尝试例如:
https://raw.githubusercontent.com/emanuelemassaro/pois/master/indonesia_education.csv
代替: https://raw.githubusercontent.com/emanuelemassaro/pois/indonesia_education.csv
答案 2 :(得分:0)
csv的真实网址是:
https://raw.githubusercontent.com/emanuelemassaro/pois/master/indonesia_education.csv
不是这个:
https://raw.githubusercontent.com/emanuelemassaro/pois/indonesia_education.csv