If your data has all the months, you can use factorize
:
DF['date'].dt.to_period('M').sort_values().factorize()
Or, you can try some math:
years = DF['date'].dt.year
months = DF['date'].dt.month
DF['date_block'] = (years*12 + months) - 2013*12
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…