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

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

Corey Schafer

4 года назад

313,331 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Corey Schafer
Corey Schafer - 17.03.2020 22:09

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.

Ответить
Michael Mitchell
Michael Mitchell - 23.10.2023 19:11

I used this video to backtrack over some material that I wasn't sure of. This was a great video as is your other instructional videos. Thanks so much.

Ответить
MrSubWright
MrSubWright - 08.10.2023 08:02

For those getting an error for accessing the datetime index, you need to sort it first now. So instead of df['2020'] make it df.sort_index()['2020'] and the same for slicing it

Ответить
tudu
tudu - 04.10.2023 15:21

df ['2019'] doesn't work for me. It gives me an error = '2019'. my 'Date' column is of data type datetime64[ns]. It also gives error in df ['2020-01-01']

Ответить
Luke Shepherd
Luke Shepherd - 27.09.2023 14:42

I got an error with the lambda function trying to parse the dates while loading from csv. The error stated pandas no longer supports pd.datetime. After checking the comments I tried @larc99's suggestion but still got an error as it was expecting a string rather than a function for the format. What gave the same output and I think is much simpler (without the lambda function) turned out to be:
df = pd.read_csv('data/ETH_1h.csv', parse_dates=['Date'], date_format='%Y-%m-%d %I-%p')

Ответить
Arty Gecko
Arty Gecko - 21.09.2023 19:13

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')

Ответить
Aditya Sharma
Aditya Sharma - 05.09.2023 19:00

TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex.
For those getting this error. Set the index of the dataframe to date.

Ответить
Gnana Deepika
Gnana Deepika - 29.08.2023 11:52

For datetime error: Just use below
df = pd.read_csv('data/ETH_1h.csv', parse_dates=['Date'], date_format='%Y-%m-%d %I-%p')

Ответить
DoctorXx
DoctorXx - 27.08.2023 20:40

```
import pandas as pd
from datetime import datetime
```
```
df = pd.read_csv('ETH_1h.csv', parse_dates=['Date'], date_format='%Y-%m-%d %I-%p')
```

```
df.head()
```

this is the new version of the code in 2023

Ответить
Jonty Roy
Jonty Roy - 15.08.2023 17:19

Did he create the series on plotting with Pandas ?

Ответить
Unish Aryal
Unish Aryal - 05.08.2023 16:06

@coreyms can you please give us the download link for ETH_1h.csv

Ответить
Shreyash Kashyap
Shreyash Kashyap - 19.06.2023 17:33

Extremely useful. Thanks for the video Corey! You have my gratitude.

Ответить
Jitin Ginotra
Jitin Ginotra - 16.06.2023 14:20

You used %I instead of %H, but the output displayed is in the format determined by %H (24 hour clock). Why is that?

Ответить
Valijon Eshniyazov
Valijon Eshniyazov - 13.06.2023 01:53

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

Ответить
curious_bun
curious_bun - 08.06.2023 06:38

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!

Ответить
Sercan 4KARDEŞLER
Sercan 4KARDEŞLER - 30.05.2023 11:37

Hello. Where can I download the 'ETH_1h.csv' file?

Ответить
kunal machineni
kunal machineni - 01.05.2023 09:19

Where is required dataframe for this video bro!

Ответить
kartikeya choudhary
kartikeya choudhary - 29.04.2023 15:49

instead of using df.set_index('Date' , inplace=True) you can also use
df=df.set_index('Date') cause in future inplace attribute will be deprecated

Ответить