python - MonthEnd object result in <11 * MonthEnds> instead of number - Stack Overflow

PHOTO EMBED

Wed May 12 2021 08:50:30 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol #python

from operator import attrgetter

df['duration_dataset'] = (
    df['date_1'].dt.to_period('M') -
    df['date_2'].dt.to_period('M')).apply(attrgetter('n'))
content_copyCOPY

https://stackoverflow.com/questions/54465030/monthend-object-result-in-11-monthends-instead-of-number/54465409#54465409