In this post, we will see how to resolve How to mark values while keep count each time we see a value?

## Question:

Does anyone know a way to count values while annotating them? For example.We have a reparative state with 3 different values. A, B, C. We want to count how many times we saw state A but values A are different length of A’s in a column. We have Column A and want to get column B. So we have time series A, B, C and we want to count time wise that A is 1 then B is 1 and C is 1 but when we again see A is 2 and B is 2 and C is 2 and the A again is 3 and so on… (The order is always the same first A then B then C and again A…)

Any ideas?

Column A | Column B |
---|---|

A | 1 |

A | 1 |

A | 1 |

B | 1 |

B | 1 |

C | 1 |

A | 2 |

B | 2 |

C | 2 |

A | 3 |

A | 3 |

A | 3 |

A | 3 |

A | 3 |

A | 3 |

B | 3 |

B | 3 |

B | 3 |

C | 3 |

C | 3 |

Tried to get a loop but don’t know how to count the state.

## Best Answer:

Here is a one way to do it :If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

## Leave a Review