【问题标题】:My python not able to read data from github我的 python 无法从 github 读取数据
【发布时间】:2023-02-01 13:39:52
【问题描述】:

这是我的代码:-

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
  dataset =  pd.read_csv('https://raw.githubusercontent.com/mk- gurucharan/Classification/master /SocialNetworkAds.csv')X = dataset.iloc[:, [0,  1]].values
  y = dataset.iloc[:, 2].valuesdataset.head(5)

它显示的错误是:-

 /Users/apple/PycharmProjects/pythonProject4 /venv/bin/python /Users/apple/PycharmProjects /pythonProject4/main.py 
   File "/Users/apple/PycharmProjects /pythonProject4/main.py", line 4
   dataset =  pd.read_csv('https://raw.githubusercontent.com/mk- gurucharan/Classification/master /SocialNetworkAds.csv')X = dataset.iloc[:, [0,  1]].values
                                                                                                                   ^
 SyntaxError: invalid syntax

 Process finished with exit code 1

为什么它无法从github读取数据

【问题讨论】:

标签: python machine-learning


【解决方案1】:

从网址中删除空格?

#                                                     HERE --v                             --v
dataset =  pd.read_csv('https://raw.githubusercontent.com/mk-gurucharan/Classification/master/SocialNetworkAds.csv')
X = dataset.iloc[:, [0,  1]].values
y = dataset.iloc[:, 2].values
print(dataset)

# Output
     Age  EstimatedSalary  Purchased
0     19            19000          0
1     35            20000          0
2     26            43000          0
3     27            57000          0
4     19            76000          0
..   ...              ...        ...
395   46            41000          1
396   51            23000          1
397   50            20000          1
398   36            33000          0
399   49            36000          1

[400 rows x 3 columns]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 2014-03-08
    • 1970-01-01
    相关资源
    最近更新 更多