Quantcast
Channel: GroupBy Pandas with ratio - Stack Overflow
Browsing all 2 articles
Browse latest View live

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 Article



GroupBy 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
Browsing all 2 articles
Browse latest View live




Latest Images