I want to drop rows with zero in the "value" column up until the index of the first non-zero value for each group.
Input
df = pd.DataFrame({'date': ['2019-01-01', '2019-01-02', '2019-01-03','2019-01-04',
'2019-01-01', '2019-01-02', '2019-01-03','2019-01-04',
'2019-01-01', '2019-01-02', '2019-01-03','2019-01-04'],
'value' : [0, 50, 100, 120, 0, 10, 0, 20, 0, 0, 10, 0],
'group': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C']
})
df
date value group 0 2019-01-01 0 A 1 2019-01-02 50 A 2 2019-01-03 100 A 3 2019-01-04 120 A 4 2019-01-01 0 B 5 2019-01-02 10 B 6 2019-01-03 0 B 7 2019-01-04 20 B 8 2019-01-01 0 C 9 2019-01-02 0 C 10 2019-01-03 10 C 11 2019-01-04 0 C
Output
date value group 1 2019-01-02 50 A 2 2019-01-03 100 A 3 2019-01-04 120 A 5 2019-01-02 10 B 6 2019-01-03 0 B 7 2019-01-04 20 B 10 2019-01-03 10 C 11 2019-01-04 0 C
Similar to Find first non-zero value in each column of pandas DataFrame, but dropping the data up until index and grouped.