I have the following dataframe:
| 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 would like to create a new dataframe where I get the min value in the column Numb if the string in the column Word is ab and the max value if the string is bc for each Date. For example, the result with the above dataframe should be:
| | | Numb |
| Date | Word | |
|------------|------|------|
| 2020/01/01 | ab | -12 |
| | bc | 34 |
| 2020/01/02 | ab | -8 |
| | bc | 123 |
I am using the following groupby function,but it only produce a dataframe with the min value in all the cases:
ans=df.groupby(['Date','Element']).min()