Sep-19-2020, 09:36 AM

Hi,

I have below dataframe:

df

Desired output:

ID Grp subGrp Rank SNO

A.1 A.0 A S 1

A.2 A.0 A S 2

A.2 A.0 A S 1

A.6 A.0 A S 2

A.3 A.0 A S 3

A.1 A.0 A S 1

A.2 A.0 A S 2

A.4 A.0 A S 3

A.2 A.0 A S 1

A.1 A.0 A S 2

A.1 rpeats & A.2 repeats but its coninuouse so not reset at A.2. A.2 rpeats again 8th row, reset and increase by one next row.

I have below dataframe:

df

ID Grp subGrp Rank SNO A.1 A.0 A S 1 A.2 A.0 A S 1 A.2 A.0 A N 1 A.6 A.0 A N 1 A.3 A.0 A S 1 A.1 A.B A 3 1 A.2 A.B A 3 1 A.4 A.0 A 3 1 A.2 A.0 A 3 1Now I want to increase SNO by 1 in each row, but reset at each repeating ID(at first repeat row) & same columns "subGrp" &"Rank"

Desired output:

ID Grp subGrp Rank SNO

A.1 A.0 A S 1

A.2 A.0 A S 2

A.2 A.0 A S 1

A.6 A.0 A S 2

A.3 A.0 A S 3

A.1 A.0 A S 1

A.2 A.0 A S 2

A.4 A.0 A S 3

A.2 A.0 A S 1

A.1 A.0 A S 2

A.1 rpeats & A.2 repeats but its coninuouse so not reset at A.2. A.2 rpeats again 8th row, reset and increase by one next row.