In the Month Return Column I need to replace NaN with a 1 except for the ros in the Category Column with the "TOTAL". I need those to sum the 1's up just after the previous "TOTAL" row. Lengths of Grouped rows (by date and Account) can vary by length.
Return Date Account Category Month Return
7/31/2003 abcdef BOND NaN
7/31/2003 abcdef CASH NaN
7/31/2003 abcdef EQUITY NaN
7/31/2003 abcdef TOTAL Nan
7/31/2003 ghijkl BOND 0.25
7/31/2003 ghijkl CASH 0.25
7/31/2003 ghijkl EQUITY 1.25
7/31/2003 ghijkl TOTAL 1.75
7/31/2003 mnopqr BOND NaN
7/31/2003 mnopqr CASH NaN
7/31/2003 mnopqr EQUITY NaN
7/31/2003 mnopqr REAL NaN
7/31/2003 mnopqr TOTAL Nan
Want it to look something like this:
Return Date Account Category Month Return
7/31/2003 abcdef BOND 1
7/31/2003 abcdef CASH 1
7/31/2003 abcdef EQUITY 1
7/31/2003 abcdef TOTAL 3
7/31/2003 ghijkl BOND 0.25
7/31/2003 ghijkl CASH 0.25
7/31/2003 ghijkl EQUITY 1.25
7/31/2003 ghijkl TOTAL 1.75
7/31/2003 mnopqr BOND 1
7/31/2003 mnopqr CASH 1
7/31/2003 mnopqr EQUITY 1
7/31/2003 mnopqr REAL 1
7/31/2003 mnopqr TOTAL 4