Answer by Timus for GroupBy Pandas with ratio
Here's an attempt:def ratios(df): df = df.reset_index(drop=True) groups = (df.Type != df.Type.shift(1)).cumsum() result = {} for t in ('A', 'B'): if t in df.Type.values: max_num =...
View ArticleGroupBy Pandas with ratio
I am working on a dataset which looks something like this:ID Amount Type1 50 A1 1000 A1 500 B1 200 B2 1000 A2 500 BI am trying to do 2 things: Find length of longest sequence of each type and find...
View Article
More Pages to Explore .....