0
C   C_val   Sum
A   A400    [150, 160]
A   A600    [160]
A   A730    [160]
B   A930    [150]
B   A1100   [100]
B   A400    [160]
A1  A400    [370]
A1  A600    [210, 370, 496]
B1  A800    [210, 496]
B1  A930    [200]
B1  A1530   [320]
B1  A730    [440, 480]
A2  A400    [578]
A2  A600    [574, 570]
B2  A800    [578]
B2  A1100   [549, 581]

I want to groupby C and C_val and reshape the dataframe as shown below

The sum is also a list and should not be a list while reshaping the dataframe.

Sum in A(col C) having val less than 200 should be in A col

Sum in A1(col C) having val between 200 and 500 should be in A1 col

Sum in A2(col C) having val between 600 and 700 should be in A2 col

Sum in B(col C) having val less than 200 should be in B col

Sum in B1(col C) having val between 200 and 500 should be in B1 col

Sum in B2(col C) having val between 600 and 700 should be in B2 col Required Output

C_val   A          A1            A2        B         B1         B2  
A400   150, 160    370           578       160
A600   160        210,370,496    574,570
A730   160                                          440,480
A930   150                                 150      200
A1100                                      100                 549,581
A1530                                               320
A800                                                           578
``

0 Answers0