What are the benefits of having 'yearmonth' column as integer vs. datetime?

Screen Link: Learn data science with Python and R projects

After completing all the missions related to the customer churn I still don´t understand the choice of the content creators to store the 'yearmonth' column as an integer type. The code seems to be unnecessarily verbose with the year*100 + month construction through all the screens.

Probably, the creation of the list of all the month in the given period is easier, considering the suggested code:

yearmonths = [y*100+m for y in years for m in months]

But besides the above, what benefits does it give us? Why not work with the datetime objects directly?

In the beginning, I thought that, probably, integer values will be used for plotting later, but, no, before plotting we formated the `yearmonth’ as a string type…

2 Likes

From what I gather it’s convention but I found a cool tidbit that with those integers you can still perform date comparisons without any string extraction eg. 20121212 > 20111212