I have this data frame:
| Date | Word | Numb |
|------------|---------|------|
| 2020/01/01 | ab | 12 |
| 2020/01/01 | bc | 24 |
| 2020/01/01 | ab | -12 |
| 2020/01/01 | bc | 34 |
| 2020/01/02 | ab | 3 |
| 2020/01/02 | bc | 123 |
| 2020/01/02 | ab | -8 |
| 2020/01/02 | bc | 12 |
I wanted to create a new data frame where I can get min value in the column Numb if my string in the column Word is ab and max value if my string is bc for each Date. For example, The output of the data frame should be:
| | | Numb |
| Date | Word | |
|------------|------|------|
| 2020/01/01 | ab | -12 |
| | bc | 34 |
| 2020/01/02 | ab | -8 |
| | bc | 123 |
I am using groupby function, but it only produces a data frame with a min value in all the cases:
ans=df.groupby(['Date','Element']).min()