Printing a data frame without index - Python

+2 votes

I have this Employee data.frame:

    Names    Designation
0    Raj         CTO
1   Rohit       Developer
2    Sam         CFO
3    Ane         CEO

I would want to print this data.frame without the index values, how can i do it?

May 17, 2018 in Data Analytics by nirvana
• 3,130 points
87,944 views
df.style.hide_index()

should do the trick
Hey thanks for sharing this trick. It really worked.
great ! I was looking for the solution for hours :)

5 answers to this question.

0 votes

You can convert the data-frame to a string and say index=False.

Below is the command:

print(Employee.to_string(index=False))
Names Designation
  Raj         CTO
Rohit   Developer
  Sam         CFO
  Ane         CEO


Hope it works!!

If you are a beginner and need to know more about Python, It's recommended to go for Python Certification course today.

Thanks!

answered May 17, 2018 by Bharani
• 4,660 points
Hi,

Anyone can help me with this...

I tried both option to print without index, also I tried myself when export to excel too,  but it still index displays.

-->Tried with 3 options...

df.style.hide_index()

print(df3.to_string(index=False))

df3.to_excel(xlwriter, sheet_name='Hindi Student', index=False)

-->My data I have like below where I am trying to export to excel

df2=df['Name'].where(df['Language'] == 'Hindi').dropna()

df3 = pd.DataFrame({'stud_sec':[section],'ListofPeople':[df2]})

print(df3)

Would appreciate your earliest response on this......
When you load your dataset, that time you can drop your index values and column name.
0 votes

Data Frame has a property named "index" which is set to true by default. If you want to print values without index then you have to set this property to false. 

print (df.to_string(index = False))

Interested in a career in data analysis? Our Data Analyst Course will equip you with the tools and techniques you need to succeed.

answered Dec 10, 2018 by Hari
0 votes
import pandas

d = ['a','b','c','d','e']
df = pandas.DataFrame(data=d)
print (df.to_string(index = False))

Output:

0
a
b
c
d
e
answered Dec 10, 2018 by Sarajit
+1 vote
.tolist() function will remove index
answered Mar 11, 2019 by nishant thakur
0 votes

Hi,

At the time of printing the data frame, you can drop the index with the index key as shown below.

print df.to_string(index=False)
answered Dec 14, 2020 by MD
• 95,460 points

Related Questions In Data Analytics

+1 vote
2 answers

Finding number of missing values and removing those missing values from a data-frame

To find number of missing values for ...READ MORE

answered Aug 14, 2019 in Data Analytics by anonymous
1,114 views
0 votes
1 answer
+1 vote
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,690 views
0 votes
1 answer

How to spilt a column of a data frame into multiple columns

it is easily achievable by using "stringr" ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,803 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,832 views
+1 vote
3 answers

How to change column names of a Data frame?

Hi, To change the name of a column ...READ MORE

answered Oct 30, 2020 in Data Analytics by MD
• 95,460 points
1,732 views
–1 vote
1 answer
0 votes
1 answer

Need help checking the validity of an image file in Python

I went through the Python documentation and ...READ MORE

answered Jan 18, 2019 in Python by Nymeria
• 3,560 points
2,306 views
0 votes
1 answer
0 votes
1 answer

Need help with making use of Pluck in Python

Hi, good question. Easy solution to be ...READ MORE

answered Jan 24, 2019 in Python by Nymeria
• 3,560 points
1,732 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP