Mr Pool
Mr Pool

Reputation: 353

How to show selected columns without Index in Python without using Print statement

I have been trying to find the display the top 10 companies from the list of 2000 based on a particular column. but the issue is when I input the variable to display the data set, it shows the index and I wanted to know is this can be done without using Print statement.

My current code is

forbes_global = pd.read_csv("Forbes_Global_2000_2019.csv")
profit_assest_company=forbes_global[['Company','Profits as % of Assets']]
profit_assest_company.sort_values(by=['Profits as % of Assets'],ascending=False).head(10)

The current output which I am getting is:

enter image description here

The desired output which I want is:

enter image description here

Can anyone help me with this?

Upvotes: 0

Views: 271

Answers (1)

Eric Truett
Eric Truett

Reputation: 3010

You can use pandas styling to hide the index in a jupyter notebook

(
  profit_assest_company
  .sort_values(by=['Profits as % of Assets'], ascending=False)
  .head(10)
).style.hide_index()

Upvotes: 1

Related Questions