2

I am working on a pandas tutorial and want to load the following data to a dataframe (I am using python 3.6 and pandas 0.23.0):

Data from URL

I know how to load data from the standard data formats (csv, excel, etc.) but have now clue how to handle the data at hand. (There probably is an easy solution (maybe already on SO?), but so far I found none as I don't even know what I am looking at exactly).

1
  • Thank you very much, I appreciate the quick, kind comeback! Commented Oct 4, 2018 at 12:53

2 Answers 2

2

Simply use read_csv, which working with url link to data very nice:

url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user'
df = pd.read_csv(url, sep='|')
print (df.head())
   user_id  age gender  occupation zip_code
0        1   24      M  technician    85711
1        2   53      F       other    94043
2        3   23      M      writer    32067
3        4   24      M  technician    43537
4        5   33      F       other    15213
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, thats exactly what I was looking for!
1

have you tried this

df = pd.read_csv('https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user',sep ='|')

Comments

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.