I have a dataframe with a lot of columns and rows (> 10000), but I need to create a column based on the minimum value from another one
Example dataframe:
So, I need the column "Cantidad min"
to contain the minimum value for that group of "CodProducto"
:
Example:
How can I do in python?
Please try follow one.
dataframe["Cantidad min"] = df.groupby(dataframe)["CodProducto"].min()
I can't test this code on your data because you didn't share yours. If it doesn't works, please provide me your data as.csv format.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.