I have a DataFrame with repeating values in the index. I would like to filter this dataset down to only show me one instance of each index by selecting the row within the index with the greatest value in a different column. For example, my DataFrame looks like this:
df:
Product ID Store Sales
1 A 50
1 B 200
1 C 20
2 A 400
2 B 10
3 A 200
4 A 50
4 B 100
4 C 500
I would like to filter this data down to this:
df2:
Product ID Store Sales
1 B 200
2 A 400
3 A 200
4 C 500
Any thoughts on how best to approach this issue in pandas?
Thanks very much for your time -
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…