Python Pandas Tutorial (Part 10): Working with Dates and Time Series Data

preview_player
Показать описание
In this video, we will be learning how to work with DateTime and Time Series data in Pandas.

In this Python Programming video, we will be learning several different concepts about working with DateTimes and Time Series data in Pandas. We will learn how to convert values to datetimes, how to filter by dates, how to resample our dates to do some more in-depth analysis, and more. Let's get started...

The code for this video can be found at:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

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

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

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

Hope you all are all staying safe! In this video we'll be learning a lot about working with dates and time-series data in Pandas, and also look at doing some basic plotting. In the next video, we'll be learning how to load in data to Pandas from different (Excel, JSON, SQL, etc). Let me know if there is anything else you'd like me to cover in the Pandas series. I will likely be taking a break from this series after the next two videos are released just so I can focus on some different topics.

coreyms
Автор

For all those getting the following error: *FutureWarning: The pandas.datetime class is deprecated and will be removed from pandas in a future version. Import from datetime module instead.*
Just do this:
*from datetime import datetime*
and change the *pd.datetime.strptime()* to:
*datetime.srtptime()*
and it should work the same.

larc
Автор

I bless the day I came across your channel

amazing-graceolutomilayo
Автор

3:50 convert to datetime using to_datetime
7:45 parse dates while loading data from csv
11:20 using day_name on whole series using dt class
12:20 create column of dayname
13:20 min and max methods on datetime series
15:00 filtering by dates as string
17:20 filter by to_datetime
18:40 set date as index
19:21 filter data by just passing the date in brackets
20:05 using a slice to get specific dates data
21:00 calculating average of a slice(timeframe)
22:05 getting max value of a column on a given day
23:50 resampling(breaking down by days) a whole column into a new variable
27:00 plotting with matplotlib in pandas
28:28 resampling df with multiple columns
30:55 using agg to apply different function on different columns while resampling

anubhavtomar
Автор

To anyone getting the message that 'date_parser' is deprecated and will be removed in a future version...

You no longer need to pass in a function, just the date string formats in the argument date_format='%Y-%m-%d %I-%p'

example:
df = pd.read_csv('ETH_1h.csv', parse_dates=['Date'], date_format='%Y-%m-%d %I-%p')

artygecko
Автор

While there are already other excellent pandas tutorials on Youtube your videos IMHO stand out for their carefully crafted examples, clarity of explanation, information density and relevance to practical applications.
I'd really love this series to be continued and cover some of the more advanced topics.

lingen
Автор

Hi Corey, thank you so much for taking the time and putting this series together. This is one of the most structured series on panda on the web. I feel confident in pandas after watching the series. We would love to see something similar on the NumPy. Please, Corey...put together a Numpy series for us.

next
Автор

Thanks a lot for this whole series Corey!! I've watched 3/4 other tutorials between youtube and other platforms and yours were the best by far, especially due to the fact that I'm from Italy so it was easier to follow your explanations step by step
I can't wait for your plotting with Pandas tutorials too, those are gonna be pretty useful! Have a nice day a stay safe ;)

ste
Автор

For anyone getting error in the first part of the video, this is what worked for me
d_parser = lambda x: pd.to_datetime(x, format='%Y-%m-%d %I-%p')
df = pd.read_csv('data/ETH_1h.csv', parse_dates=['Date'], date_parser=d_parser)

LegendaryGamer-pxdp
Автор

Also to get the mean for resampling, the default for the mean function was changed. So to get the weekly resampling at around 30:05 of the video:

df.resample('W').mean() will give an error

do this instead:


MrSubWright
Автор

The concept of resample is so damn crazy!!! I struggle so much in other systems with this kind of aggregation and it's easy like nuts in pandas...

Corey, you are great!

ashishdeora
Автор

I learn through this video in 2023 as a new entry-level data analyst and non-native English. It's still relevant and lite but packed, especially for the `.resample()` method. It saves my time compared to using `.groupby()`. In addition, we need to keep in mind indice filtering. It's better to use `.loc[]` to avoid the deprecation issue. Thank you, Corey Schafer. Your channel is such a gem!

zio.eza
Автор

this whole series is so beautifully explained that if one is little bit aware of python and its syntax whole series can be watched without volume .

piyushkonher
Автор

Thank you Corey for the wonderful tutorials. No paid courses can come close to the way you present the depth of the concept. Thank you for making it free and a big thank you for keeping up the good work.

hermancoutinho
Автор

These are the most developed, best explained videos on how to use pandas - thank you Corey for putting these together!

ZsoltPal
Автор

Starting at 8:02

You may use this instead

*df = pd.read_csv('data/ETH_1h.csv', parse_dates=['Date'], date_format = '%Y-%m-%d %I-%p')*

HaithamGaafer
Автор

Right now I'm learning flask from your playlist and it's freaking amazing!

electromorphous
Автор

Yesterday i was searching for any tutorial that explains dates and times in pandas and i couldn't find a good material
Thanks man

mahmoudgamal
Автор

I really appreciate your detailed explanation on the errors, which help us to select the right corrective action to take. Love your videos.

aatt
Автор

Very, very, very good. The accurate and straightforward explanations are supported by great examples. Big thanks.

benjamindeporte