John Montana
John Montana

Reputation: 175

How to print a row of a data frame with single spaces between the cells?

Output of the following code is: 0 A B C D

data = pd.read_csv("file") 
print(data.loc[[0]].to_string(header=False ))

Which has 2 empty spaces between each variable. Why does it have 2 empty spaces? Is there a way that I can make it with one empty space between each cell(without for loop)?

Upvotes: 0

Views: 81

Answers (1)

Dersu Giritlioğlu
Dersu Giritlioğlu

Reputation: 316

This might be a fast solution but it works. Try adding: .replace(' ',' ') at the end of printed string.

Upvotes: 1

Related Questions