Matplotlib Tutorial 11 - handling unix time

preview_player
Показать описание
In this Matplotlib tutorial video, we're going to cover how to handle the conversion of unix time stamps to then plot date stamps in your graph. With the Yahoo Finance API, you will notice that if you use large time frames, like 1y for one year, you will get those date stamps we've been working with, but, if you use something like 10d for 10 days, you will instead get timestamps that are unix time.

Unix time is the number of seconds after Jan 1st 1970, and it represents a normalized method for time across programs. That said, Matplotlib doesn't want unix time stamps.

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

Why can't Matplotlib just use python Datetime? These endless types of date are so annoying.

pier-oliviermarquis
Автор

is there a unixtime datafile to use with this tutorial?

markd
Автор

I get an error when I remove converters on the same line

rahulraja
Автор

Thanks for the video, I'm hoping we'll get to having time (hh:mm) on the x-axis?

msduff
Автор

Hmm, this is the conversion in Python, but how can i get a time axis in matplotlib? I can plot the horrible Unix time but not 12:08:22 for example. I tried 3 different Tutorials - none works.

marcusfallen
Автор

Love the videos. Just have one question. I have a timestamp column in my csv file formatted (Wed Jun 22 20:00:01 EDT 2016). I want to use this for the x-axis. Would it be best to convert this to a more standard datetime (2016-06-22 20:00:01) or unix/epoch time (1466640001)? Looking at the date2num and num2date just not sure which would be easiest to do. BTW - My plots are using np.loadtxt to get the x, y data from the csv file.

tripodmaster
Автор

Hey sir you forget to get one line after unpack='true' in sample code in your site please just add converter={0 :bytespdate2num('%Y%m%d')}

shubhankartripathi
Автор

Can someone please explain what the function of np.vectorize is???

hannahtang
Автор

i cant plotting graph using your given stock_price_url.


i get this eroor ->> ValueError: time data '<html>' does not match format '%Y%m%d'

janakkapuriya
Автор

Awesome stuff. thank you for putting this out here!

GurnBograt
Автор

nice video! There's a problem for me that I cant open this link. could you tell me what i need to do before i want to open this api?

tianfangliu
Автор

wow it's gotten a lot more quieter in the comment section since the earlier videos. the pack has thinned out!

kas
Автор

Good job, this is my first time taking python can you produce more of this series.
que: i want you produce a special episode for me, importing data from excel like for performance analysis for monthly sales. thanks. am following 100%

ebrimasowe
Автор

sir i am facing a problem in this and can't handle it so please help me sir -- ValueError: could not convert string to float: '2017-07-26'

ashishthaakur
Автор

Hi, because the date format in the new url is something like "2018-1-1". Use numpy.loadtxt() to read the data will show error that:


ValueError: could not convert string to float: '2018-1-1'

Obviously '2018-1-1' could not convert to float cause it is not a number. So how to handle this problem? Convert it to '20180101'? How to do it?

mozarter
Автор

Extra credit! I unpacked the values just like you did, and removed the converter just like you did. Then I used np to convert the existing timestamp numpy array to datetime64. Then called tolist() to turn timestamp into a list of datetime.datetimes.

For more info:

kas
Автор

Brilliant. I simply love your tutorials. However, I'm still wondering what is the chartapi all about?
I have no idea how you can display the data in such way that it is so easy to handle...
Could you point me to a right direction?

akiriisio
Автор

np.vectorize()? What does that do? [off to the search engine]

stermister
Автор

There is string to floating conversion error

nv.paraboy
Автор

import smth.smth as smth... this shit is a gotcha of python because it does not have one file - one class package structure like java, but it is not stated directly in official docs, and many std modules don't even have classes inside but only defs.

ruslansmirnov