Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

How would I groupby and rank in Pandas while excluding one value of the group?

$
0
0

Say I have this dataframe pictured in the 1st screenshot below, I want to rank the scores by Day without considering the "Total" value for each group.

The 2nd screenshot below is what I would like the output to look it.

What's an efficient way to do this?

data = pd.DataFrame({'Day':['Monday','Monday','Monday','Monday','Tuesday','Tuesday','Tuesday','Tuesday'],'City':['NY','Chicago','Miami','Total','NY','Chicago','Miami','Total'],'Score':[100,90,70,260,120,80,90,290]})

enter image description here

enter image description here


Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>