Going fast! #DataquestChallenge Premium Annual Offer:
500 get 50% & the next 1000 get 40% off.
GET OFFER CODE

Sharing Guided Project Exploring Hacker News Posts

Hi all, I just finished my second guided project.

I was able to work on everything but I struggled with the timezone convertion in the end (when we are asked to convert the datetime stamp to our local timezone). I just ended up using time span.

Has anyone managed to use the astimezone?

https://app.dataquest.io/m/356/guided-project%3A-exploring-hacker-news-posts/8/next-steps

Exploring Hacker News Posts.ipynb (19.1 KB)

Click here to view the jupyter notebook file in a new tab

3 Likes

Hi anabiagandolfi!
Whoa, I tried to figure out how the astimezone system worked, and it seems like it is implemented as a framework, rather than a built-out class. It was all really confusing, and to be honest, did not seem worth working through.
If you want, you can probably build a quick function that can take in a time, the current timezone, and the desired timezone and output the correct time. The pseudo-code would look something like this:

def change_tz(current_tz, new_tz, datetime_object):
    # pass current_tz and new_tz in as the number of hours different from UCT (ie Chicago = -5)
    time_difference = new_tz - current_tz
    updated_datetime_object = datetime_object.updatetime(time_difference)
    return updated_datetime_object

Sorry I am having a lot of trouble with markup…trying to fix it now.

Yes! It was so confusing that I just gave it up.

But the function is a good idea indeed, thank you for sharing.