Open In App

How to print Dataframe in Python without Index?

Last Updated : 22 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

When printing a Dataframe, by default, the index appears with the output but this can be removed if required. we will explain how to print pandas DataFrame without index with different methods.

Creating Pandas DataFrame without Index 

Python3
import pandas as pd

df = pd.DataFrame({"Name": ["sachin", "sujay", "Amara", "shivam", 
                            "Manoj"],

                   "Stream": ["Humanities", "Science", "Science", 
                              "Commerce", "Humanities"]},

                  index=["A", "B", "C", "D", "E"])

print("THIS IS THE ORIGINAL DATAFRAME:")
display(df)
print()

Output:

 

Print DataFrame without index by setting index as false

To print the Pandas Dataframe without indices index parameter in to_string() must be set to False.

Python3
print("THIS IS THE DATAFRAME  WITHOUT INDEX VAL")
print(df.to_string(index=False))

Output:

Pandas DataFrame without Index
 

Print DataFrame without Index using hide_index()

Printing Pandas Dataframe without index using hide_index()

Python3
#Using hide Index
df.style.hide_index()

Output:

Pandas DataFrame without Index
 

Print DataFrame without Index using by making Index empty

Printing Pandas Dataframe without index by making Index empty.

Python3
# Print DataFrame without index 
blankIndex=[''] * len(df)
df.index=blankIndex
print(df)

Output:

Pandas DataFrame without Index
 

Next Article

Similar Reads