def period_break(dates, period):
 current = getattr(dates, period)
 previous = getattr((dates - 1), period)
 return (current - previous).nonzero()[0]

def period_break ( dates , period ) : current = getattr ( dates , period ) previous = getattr ( ( dates - 1 ) , period ) return ( current - previous ) . nonzero ( ) [ 0 ]
returns the indices where the given period changes .