Pandas rank by column value [duplicate]

Here’s one way to do it in Pandas-way You could groupby on Auction_ID and take rank() on Bid_Price with ascending=False In [68]: df[‘Auction_Rank’] = df.groupby(‘Auction_ID’)[‘Bid_Price’].rank(ascending=False) In [69]: df Out[69]: Auction_ID Bid_Price Auction_Rank 0 123 9 1 1 123 7 2 2 123 6 3 3 123 2 4 4 124 3 1 5 124 2 … Read more

ImportError: IProgress not found. Please update jupyter and ipywidgets although it is installed

I tried everything you mentioned in a new environment using conda and I had another issue related to the version of ipywidgets (a bug found in Github with comments saying that got solved after using last version). I solved the problem I had installing last version of ipywidgets. Here is my process: Create a new … Read more

Python Pandas: drop a column from a multi-level column index?

With a multi-index we have to specify the column using a tuple in order to drop a specific column, or specify the level to drop all columns with that key on that index level. Instead of saying drop column ‘c’ say drop (‘a’,’c’) as shown below: df.drop((‘a’, ‘c’), axis = 1, inplace = True) Or … Read more