I have a dataframe containing the columns "Date", "Snow_depth" and "hydro_year". The "Snow_depth"-column contains values from 0-150. To identify the number and length of continuous snowdays, meaning days with "Snow-depth"-values greater than 0, I´m trying to add a column which contains ascending numbers starting from the first "Snow-depth"-value greater than 0 and ending with the next 0 of the "Snow-depth"-column + Zeros/NAs for each row with a "Snow-depth"-value of 0. As soon as I got this I would then count the number of "2"-values of that new column (since 2 days is the minimum for a snow-period) to detect the number of periods and also filter the hightest and lowest values for each hydroyear to detect the max- and min-length.
Does anyone know how to create that column I described?
What I need shpuld look like this:
Snow_depth: 0, 0, 5, 7, 8, 4, 0, 0, 6, 5, 8, 9, 5, 6, 0, 8, 6...
New_column: 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2...
Any help would be much much appreciated! Thanks!