Puzzle 3: Month by Month

Let's exercise our minds by solving a pandas DataFrame puzzle.

We'll cover the following

Guess the output

Try to guess the output of the code below:

Press + to interact
from io import StringIO
import pandas as pd
csv_data = '''\
day,hits
2020-01-01,400
2020-02-02,800
2020-02-03,600
'''
df = pd.read_csv(StringIO(csv_data))
print(df['day'].dt.month.unique())

Quiz

Q

What is the output of the code above?

A)

AttributeError

B)

[1 2]

C)

[1]

D)

SyntaxError

Get hands-on with 1300+ tech skills courses.