Puzzle 16 Y3K

Pandas Brain Teasers — by Miki Tebeka (24 / 34)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Free-Range | TOC | Not My Type 👉

future.py

​ ​import​ ​pandas​ ​as​ ​pd​

​ y3k = pd.Timestamp(3000, 1, 1)
​ ​print​(f​'They arrived to Earth on {y3k:​​%​​B ​​%​​d}.'​)

Guess the Output

IMPORTANT

Try to guess what the output is before moving to the next page.

images/hline.png

This code will raise an OutOfBoundsDatetime exception.

images/hline.png

Computers and time have a complicated relationship. There are daylight saving time, leap years, time zones, and more details to work out.

Computers store time as the number of seconds since January 1, 1970, GMT.

2038

WARNING

This means that in 2038, time will overflow on 32-bit machines. Ouch!

Python’s datetime and pandas.Timestamp, which is based on it, are written mostly in C and have a fixed amount of space for storing time information. This means there’s a maximal and minimal value to datetime.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.