My DataFrame looks like this:
Category Date
81 Monate 2020-01-01
88 Monate 2020-01-02
58 Monate 2020-01-03
3 Monate 2020-01-04
23 Monate 2020-01-05
.. ... ...
134 Wochen 2020-05-24
145 Tage 2020-05-25
147 Tage 2020-05-26
146 Tage 2020-05-27
148 Tage 2020-05-28
It is ordered by Date. I need to run a check if on each row Monate follows Monate, Wochen follows Wochen and so on. It is allowed that Wochen follows Monate and Tage follows Wochen. I hope it is clear that I mean. Something looks this should cause an error, since the sequence is invalid.
Category Date
81 Monate 2020-01-01
88 Monate 2020-01-02
58 Tage 2020-01-03
3 Monate 2020-01-04
23 Monate 2020-01-05
.. ... ...
134 Wochen 2020-05-24
145 Tage 2020-05-25
147 Tage 2020-05-26
146 Wochen 2020-05-27
148 Tage 2020-05-28
I could try to write a pretty complicated and probably slow iteration over each row.
for row in result_df.iterrows():
do xyz
Is there a better and quicker way to check for an ongoing sequence in a Series or a maybe in a list, dictionary etc.?