Matplotlib Tutorial (Part 8): Plotting Time Series Data




[ad_1]

In this video, we will be learning how to plot time series data in Matplotlib.

This video is sponsored by Brilliant. Go to https://brilliant.org/cms to sign up for free. Be one of the first 200 people to sign up with this link and get 20% off your premium subscription.

In this Python Programming video, we will be learning how to plot time series data in Matplotlib. Time series data consists of data that contains dates. For example, in this video, we will be plotting BitCoin prices over the last few weeks. We will learn how to format dates in different ways so that they work better with our graphs. Let’s get started…

The code from this video (with added logging) can be found at:
http://bit.ly/Matplotlib-08

Datetime Tutorial – https://youtu.be/eirjjyP2qcQ
Datetime Format Codes – http://bit.ly/python-dt-fmt

✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website – http://coreyms.com/
My Second Channel – https://www.youtube.com/c/coreymschafer
Facebook – https://www.facebook.com/CoreyMSchafer
Twitter – https://twitter.com/CoreyMSchafer
Instagram – https://www.instagram.com/coreymschafer/

#Python #Matplotlib

Source


[ad_2]

Comment List

  • Corey Schafer
    November 22, 2020

    I hope everyone finds this video helpful. The next video of the series will be posted tomorrow at the same time. The next video will cover how to plot live data in real-time. We will learn how to monitor a CSV file for changes and add that data to our plot as it's being generated, so be sure to check that out.

    I'd like to thank Brilliant for sponsoring this series. If you'd like to check them out then you can sign up with this link and get 20% off your premium subscription:
    https://brilliant.org/cms

  • Corey Schafer
    November 22, 2020

    If the dates are not arranged in order in your list and you use solid line…the dates will be arranged according to time, but the y values will be connecet to each other as they appeared in the list…and that will look very weird graph, having many intersecting lines

  • Corey Schafer
    November 22, 2020

    Thanks man!!

  • Corey Schafer
    November 22, 2020

    How to add percentage change from one point to another in the plot that you have shown.

  • Corey Schafer
    November 22, 2020

    Thank you very much for very nice series of videos.

    I am following all the videos.

    Only in the present video it show the error about itertools.
    I try to install it using pip as well as conda but can't do that.

    the i try to install pip3 install more-itertools.
    it says the requirements already satisfied.
    but still same error.

    I am using Windows10 64 bit and using Spyder4 editor (comes with anaconda installation).
    Your kind help in this regard is highly appreciated.

  • Corey Schafer
    November 22, 2020

    Thank you for this amazing series. Being a fellow python creator aswell, I really appreciate the amount of effort you put into creating this amazing tutorials, and all the best for the future :))

  • Corey Schafer
    November 22, 2020

    14:00 I think even without pd.to_datetime() conversion (line 10), pd.sort_values() (line 11) will still work as expected, since treating dates as strings will still produce the same plot. Am I right?

  • Corey Schafer
    November 22, 2020

    What about plotting hours:minutes:seconds, i suppose that it can't be done with dates,and i need timestamp format for that?

  • Corey Schafer
    November 22, 2020

    This is such an informative video. Really appreciate how u explained each and every thing !

  • Corey Schafer
    November 22, 2020

    I feel that I love you!, Thanks for share all this videos bro!!

  • Corey Schafer
    November 22, 2020

    11: 44 We could sort the strings here, as we sort the dates later. We would get the same. We do not have a May 17th at the beginning because we didn’t sort, not because those aren’t dates. Am I right?

  • Corey Schafer
    November 22, 2020

    Just come across that in pandas they have date_range function.

  • Corey Schafer
    November 22, 2020

    Hey Corey! Thanks a lot for the videos. Could you create some more videos that cover Time Series in detail please? I have gone through the one on your channel and its great, but I guess it would be really helpful if you create more on it with examples. There's very less content that I found good related to Time-series and I'm sure your videos would solve that issue.

  • Corey Schafer
    November 22, 2020

    the best lecture i have found on youtube. DO share some more resources

  • Corey Schafer
    November 22, 2020

    What about plotting data by date when you're just looking for how many events took place in a time frame? For example, how many customer bought x, y and z product in 2019? Or by quarter? Data sets don't always track data by date in each row like stock or coin prices.

  • Corey Schafer
    November 22, 2020

    Excellent video. Thanks for sharing.

  • Corey Schafer
    November 22, 2020

    what python program did u use to code this?

  • Corey Schafer
    November 22, 2020

    what about datetime? how to set ticks for date time axis

  • Corey Schafer
    November 22, 2020

    This is beautiful

  • Corey Schafer
    November 22, 2020

    Great video as always, but how we can adjust if we have time also? Because in some datasets where the time-interval in minutes we probably have the time with date also.

  • Corey Schafer
    November 22, 2020

    How do you use the # symbol such it will either show on many lines of code AND delete all of them in a shortcut?

  • Corey Schafer
    November 22, 2020

    excellent tut as always. Any thoughts on how to make the month lower case; as in I'd like to get "may-19" instead of "May-19". Thanks

  • Corey Schafer
    November 22, 2020

    error at df = pd.to_datetime(df)

    to assemble mappings requires at least that [year, month, day] be specified: [day,month,year] is missing.

    i dont have days or months or years i only have like '09:00:00.036' %H:%M:%S.%f but its given me error … please help me …. i only want to show the given h,m,s.f …….days years and monhs are not given in dataset

  • Corey Schafer
    November 22, 2020

    @corey: how to plot candlesticks with volume

  • Corey Schafer
    November 22, 2020

    Could any intelligent human tell me how can I animate vectors (arrows) in Matplotlib. I've tried many different ways and they either not move the vector or Python gives an error (something like: You can not update data from vector, plt/ax.arrow).
    I'm a noob and I've been stuck for a while with this problem, so I would really appreciate ANY idea.
    Thanks

  • Corey Schafer
    November 22, 2020

    Thank you for help @corey

  • Corey Schafer
    November 22, 2020

    Those who come up with this question:
    Why I can't replace these:

    data['Date'] = pd.to_datetime(data['Date'])
    data.sort_values('Date', inplace=True)
    price_date = data['Date']
    price_close = data['Close']
    with
    price_date = pd.to_datetime(data['Date'])
    data.sort_values('Date', inplace=True)
    price_close = data['Close']
    that is because you need to sort data before you write your x-axis data

  • Corey Schafer
    November 22, 2020

    Amazing work Corey! I enjoy your videos and will be watching as many as possible! love the work!

  • Corey Schafer
    November 22, 2020

    Awesome videos! Do you plan on doing videos on Pandas? That’d be great!

  • Corey Schafer
    November 22, 2020

    if you pass this arg parse_dates=True into the csv function. It doesn't do the trick for you?

  • Corey Schafer
    November 22, 2020

    Corey, your videos are awesome. Learning lot from these. Would like to see more videos on machine learning, neural networks as well

  • Corey Schafer
    November 22, 2020

    Thanks a lot.The series is awesome

  • Corey Schafer
    November 22, 2020

    Awesome Video Series. I have followed all your python series and OOPs in python 🙂 and i love those very much. I am highly interested to know what will the next chapter we are going to learn from you?

  • Corey Schafer
    November 22, 2020

    please can you show how to plot multidimensional time series. i love your videos

  • Corey Schafer
    November 22, 2020

    Very nice. Is their any way to use the rest of the columns tho? Can u make a graph that includes high, low, closing value and volume? Does a graph like that even make sense? Or can u do some tips of aggregations if u had more than one currency, for instance what if u had a similar table but with euros, pounds and yuan mixed in too? Sorry for the long question 🙂

  • Corey Schafer
    November 22, 2020

    The whole matplotlip is awesome. I keep watching them on and on.

  • Corey Schafer
    November 22, 2020

    Please explain how to visualize a multi-class time series classification dataset with different DateTime formats in a single column. The time interval of the recording of each sample measurement is every 15 minutes. Please find the link to the dataset for reference -"https://www.hackerearth.com/problem/machine-learning/on-the-plague-trail/"

  • Corey Schafer
    November 22, 2020

    – video liked
    – beer opened
    – watching video

  • Corey Schafer
    November 22, 2020

    Great!

  • Corey Schafer
    November 22, 2020

    I just realized that I'm missing a date in my CSV data. I fixed that in the snippets, so if you're following then there will no longer be a missing date in the downloaded snippets. But we can see that even with the missing date in the video, it interpolates the values for that missing date in the plot.

  • Corey Schafer
    November 22, 2020

    Great info!

  • Corey Schafer
    November 22, 2020

    Sir, I need some help about Django raw queries. Please help me.

  • Corey Schafer
    November 22, 2020

    Thx a lot for making this series!

Write a comment