dataFrame:
ProName ProCat Price
EJBR45 EL 5432.00
XYCK23 MH 656.00
RMX57 EL 8787.00
FG567 CO 56548.00
GHK245 EC 56456.00
EJBR45 EL 6665.00
XYCK23 MH 6576.00
RMX57 EL 15465.00
FG567 CO 78887.00
GHK245 EC 54654.00
EJBR45 EL 43556.00
XYCK23 MH 98445.00
FG567 CO 65436.00
GHK245 EC 654365.00
In SQL I use below query:
select ProName, ProCat, max(Price) as Price
from Dtatatatata
group by ProName,ProCat
Results:
ProName ProCat Price
FG567 CO 78887.00
GHK245 EC 654365.00
EJBR45 EL 6665.00
RMX57 EL 8787.00
XYCK23 MH 98445.00
Can we do this in python?
I have tried Python : Getting the Row which has the max value in groups using groupby but did not understand. Please guide
Applied in 1.5Million records dataframe, Performance is too slow:
distData = dataAll.set_index(['Donor', 'Recipient', 'Commodity Aggregation Type', 'Aid Category', 'Measure', 'Unit', 'Frequency', 'Date']).max(level=[0,1,2,3,4,5,6,7]).reset_index()