Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing a pandas dataframe without row number/index [duplicate]

Tags:

python

pandas

Using the following code:

predictions  = pd.DataFrame([x6,x5,x4,x3,x2,x1])
print(predictions)

Prints the following in the console:

            0
0  782.367392
1  783.314159
2  726.904744
3  772.089101
4  728.797342
5  753.678877

How do I print predictions without row (0-5) or column (0) indexes?

In R the code would look like:

print(predictions, row.names = FALSE)
like image 527
ZJAY Avatar asked Sep 19 '18 00:09

ZJAY


People also ask

How can I print a DataFrame without indexing?

Using DataFrame. to_string() to Print DataFrame without Index. You can use DataFrame. to_string(index=False) on the DataFrame object to print.

How do I get rid of row numbers in pandas?

You can delete a list of rows from Pandas by passing the list of indices to the drop() method. In this code, [5,6] is the index of the rows you want to delete. axis=0 denotes that rows should be deleted from the dataframe.


1 Answers

print(df.to_string(index=False, header=False))
like image 124
yoonghm Avatar answered Sep 22 '22 12:09

yoonghm