【问题标题】:download csv file dat from github从 github 下载 csv 文件 dat
【发布时间】:2022-01-20 10:51:50
【问题描述】:

我正在尝试将 github 中的 csv 文件中的数据下载到数据框中 代码: 将熊猫导入为 pd url = "https://github.com/lazyprogrammer/machine_learning_examples/blob/master/linear_regression_class/data_2d.csv" r = requests.get(url+file) pd.read_csv(url,names = ['X1','X2','y'])

似乎 html 页面数据存储在数据框中,而不是加载文件数据: enter image description here

【问题讨论】:

    标签: python csv file github download


    【解决方案1】:

    试试这个:

    import pandas as pd
    url = "https://github.com/lazyprogrammer/machine_learning_examples/blob/master/linear_regression_class/data_2d.csv"
    df = pd.read_csv(url,index_col=0,parse_dates=[0])
    
    print df.head(5)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-12
      • 2011-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      • 2016-01-09
      相关资源
      最近更新 更多