Open In App

How to print Dataframe in Python without Index?

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 




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.




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

Output:



 

Print DataFrame without Index using hide_index()

Printing Pandas Dataframe without index using hide_index()




#Using hide Index
df.style.hide_index()

Output:

 

Print DataFrame without Index using by making Index empty

Printing Pandas Dataframe without index by making Index empty.




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

Output:

 


Article Tags :