Matplotlib Tutorial 8 - getting data from the internet

preview_player
Показать описание
Aside from loading data from the files, another popular source for data is the internet. We can load data from the internet from a variety of ways, but, for us, we're going to just simply read the source code of the website, then use simple splitting to separate the data.

Рекомендации по теме
Комментарии
Автор

Unfortunately, Yahoo decided to remove their API. To handle for this, you can change the stock_price_url to the following in the code:


Only AAPL is supported. If you have your own source, feel free to adapt the code to suit that, or you can look into pandas for pulling data.

sentdex
Автор

Huge thanks for these videos! I found a way to pull data for this module.

1. First, you must have a current installation of pandas (check version with: import pandas as pd, pd.__version__).
2. Second, you have to install pandas_datareader (pip install pandas_datareader)
3. Then, at least if you're running version 20.3, these lines will pull in the data:

from pandas_datareader import data, wb
df = data.DataReader('TSLA', 'yahoo')
df

My finished function (for this module) looked like this, and I didn't have to do all the date manipulation:

def graph_data(stock):
df = data.DataReader(stock, 'yahoo')
plt.plot_date(df.index, df.Close, '-')

plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Interesting Graph')
plt.legend()
plt.show()

graph_data('TSLA')

Hope this helps!

MelissaCirtain
Автор

Too bad I didn't buy TSLA when this video came out. $30/shr then, >$1000 today.

mitchellfolbe
Автор

I've been losing my mind trying to learn Python and data. Your vids are THE BEST resource I've found so far. THANK YOU VERY MUCH.

InsightThoughtSystems
Автор

How did you get the data on web looking like that? When I try to manually navigate to Teslas stocks, I can't see anywhere the option to open the data as csv

akiriisio
Автор

Thanks for posting this video, I got my code to work with the new url, but it was a bit confusing going thru the for loop. Might have to watch another time, regardless, your videos in general so far are GREAT. Thanks

TRNDSETR
Автор

hey sentdex I know this is an old tuts, but quick question in the data we had to account for the 'values' line bc it had 6, but 'labels' line right above also has 6 and each one is a date but we didn't have to account for that line.... also if this is a csv then why does each line besides the actual values were looking for start with a title then a colon then the Csv data. KIND OF LOOKS LIKE JSON, example= values: date, close, high, low, open, volume is each line a Dict of some sort or is it JSON
----also no matter what id do im getting a URLLIB open error. SSL cert verify failed!!!!

sodapopinski
Автор

Hey, how do you make new line just exactly under the end of previous line but not of its begining?

maxon
Автор

Upto which video I should watch in matplot to get knowledge enough to start machine learning

sidharthkumar
Автор

Hellos for everybody, please help:
My comp says that "urllib" has no attribute "request".
What should i do?

hurlimanjumamuratova
Автор

you could filter out the un-needed data by checking for a number at the beginning of the line.

joebasilmarji
Автор

Awesome tutorials! I'm trying to move to Open Source and this is exactly what I was looking for!

Andrumen
Автор

You forgot to put the link in the description.

sumwun
Автор

Hi sentdex, is there anyway that i'm able to tell python to recognise only the very last trade day's values from yahoo finance's chartapi?
Example, if i was to run it today(sunday), it would recognise data from last friday.
And also, how do i assign the data(high, low, open, close, volume) for the last trade day individually to 5 variables?
Thanks in advance!
ps. love your videos, pls keep them going!! :D

ssakthi
Автор

Hello, your videos are really helpful. But in this excercise am getting an error.
indexError: list assignment index out of range.
I don't know why. Thanks for the videos

abubakaradam
Автор

Link is now different, which means the data is different, which mean the code in the video is wrong. I fixed all this before discovering Tomer Cna'an's comment below, but honestly, this video should either be redone, deleted, or have some sort of disclaimer upfront mentioning these issues...

jenniferchen
Автор

can some one explain why after reading the data, the date is an array like this:
array([736536., 736535., 736534., ..., 730124., 730123., 730122.])

Does the number represent tick?

mozarter
Автор

i am trying to do the same as u did to get data from internet but i am getting an error, i am using python 2.7, what change i need to make.please help me out

paritoshtripathi
Автор

Hi, Your tutorials are very useful, why not you use jupyter notebook?

sameerali
Автор

I'm getting an error saying : stock_data is not defined? Please help

kohli