download csv file dat from github

Viewed 440

I am trying to download data from a csv file in github to a data frame code: import pandas as 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'])

Instead of loading file data it seems that the html page data is stored in the dataframe: enter image description here

1 Answers

try this:

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)
Related