Data Science Jumpstart with 10 Projects Transcripts
Chapter: Project 6: Working with Time Series - Air Quality over Time
Lecture: Converting Dates to Italian time in Pandas and pytz
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Okay, let's look at how to convert to a different time zone. I want to convert to Italian time zone
0:06
I'm going to import this pits library. This is a time zone library. This has a nice attribute called all time zones Let's look at the Europe time zones
0:16
Okay, it looks like there is a Europe Rome in there once I have a column let's try and localize it
0:23
I'm going to try and stick into Rome time it complains and it says this is a non-existent time
0:29
How is it possible to have non-existent times when you have daylight savings? You actually lose an hour or you gain an hour
0:35
and so there is a time in there where it's either overlapping or it's spaced out and
0:40
So you have an ambiguous time where it's overlapping or when it's spaced out you have a time that's impossible
0:46
And so it turns out that we have an impossible time here. How do we get around this?
0:51
We actually need to convert this to UTC time first before we convert it to Italian time
0:57
So let's run that and when we run that we can see that that converts
1:00
Okay, let's try that with our pie arrow time it looks like it works with pie arrow time as well Just a Small note here
1:15
CET to be pedantic is not a time zone but it does work for localization it understands it but
1:24
Time zone people will tell you that that is not a time zone time zone should be associated with a location