Reputation: 447
I have a dataframe with following columns and index :
first sec
0 z 50
2 b 3
1 a 3
4 c 2
5 e 1
I want to print this plain output :
z 50
b 3
a 3
c 2
e 1
I have used to_string , but its not giving desired results , i have used some loops too , but nothing is giving desired results
Upvotes: 0
Views: 116
Reputation: 59274
Use to_string
specifying header
and index
to be None
>>> print(df.to_string(header=None, index=None))
z 50
b 3
a 3
c 2
e 1
If you want exactly your output, you can play with the series by adding exactly one space and then your next series.
>>> x = df['first'].add(' ').add(df['sec'].astype(str)).to_string(index=None).replace('\n ', '\n')
z 50
b 3
a 3
c 2
e 1
Upvotes: 2