2

After importing the following libraries, I am trying to read a CSV file from here.

    `import pandas as pd
     import numpy as np
     import matplotlib.pyplot as plt
     from sklearn.linear_model import LinearRegression
     from sklearn.metrics import r2_score
     import statsmodels.api as sm
     from pandas.core import datetools`

    `data = pd.read_csv("https://github.com/marcopeix/ISL-linear-` 
     regression/blob/master/data/Advertising.csv", sep='delimiter', 
     header=None,` `engine='python')`

May I please request someone to explain the reason why I am getting HTML tags as output..

`data.head(5)`

  ` 0
    0   <!DOCTYPE html>
    1   <html lang="en">
    2   <head>
    3   <meta charset="utf-8">
    4   <link rel="dns-prefetch" href="https://assets-...`

1 Answer 1

2

If you go to the Github page, you will find Raw in the right end as shown in screenshot below. Click the Raw and copy the url of that.

enter image description here

Here is the right url for you:

import pandas as pd
data = pd.read_csv("https://raw.githubusercontent.com/marcopeix/ISL-linear-regression/master/data/Advertising.csv")
Sign up to request clarification or add additional context in comments.

1 Comment

It made sense. Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.