0

Let's say I have this dataframes

id | codoper | CodProd  | valor
-------------------------------
1  | 00001   | 55       | 45000
2  | 00002   | 18       | 45000
3  | 00003   | 33       | 53000
4  | 00001   | 19       | 32000
5  | 00004   | 73       | 32000
6  | 00004   | 74       | 32000
7  | 00004   | 75       | 32000
8  | 00004   | 99       | 32000

The idea is obtain a "dataframe B" with the list product DataFrame Result:

00001 | 55 | 19 | NaN| NaN
00002 | 18 | NaN| NaN| NaN
00003 | 33 | NaN| NaN| NaN
00004 | 73 | 74 | 75 | 99 

I Try this, but not work

df_operaciones.head.groupby(['CodProd'], as_index=False).min()

Note: The values lost can be Nan or 0

Thanks a lot

0 Answers0