'How MonthEnd(1) function works?

MonthEnd function offset the date to end of month as given below. But I am not clear how it works? Does it scan the left side of '+' sign and then calculate the number of days to add? Normally we expect something like MonthEnd(Date).

import pandas as pd
from pandas.tseries.offsets import MonthEnd

df = pd.DataFrame({'Date': [20010410, 20050805, 20100219, 20160211, 19991208, 20061122]})
df['EndOfMonth'] =  pd.to_datetime(df['Date'], format="%Y%m%d") + MonthEnd(1)

print(df['EndOfMonth'])

0 2001-04-30
1 2005-08-31
2 2010-02-28
3 2016-02-29
4 1999-12-31
5 2006-11-30
Name: EndOfMonth, dtype: datetime64[ns]



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source