I have a dataframe like:
0 1 2 3 4 5 6 7 8 class
0 0.4444 0.0000 0.0000 0.0000 0.1111 0.0000 0.2222 0.0000 0.0000 0
1 0.4444 0.3333 0.3333 0.4444 0.6667 1.0000 0.2222 0.1111 0.0000 0
2 0.2222 0.0000 0.0000 0.0000 0.1111 0.1111 0.2222 0.0000 0.0000 0
All I want this to be printed on console without newline and without column names:
0.4444,0.0000,0.0000,0.0000,0.1111,0.0000,0.2222,0.0000,0.0000,0
0.4444,0.3333,0.3333,0.4444,0.6667,1.0000,0.2222,0.1111,0.0000,0
0.2222,0.0000,0.0000,0.0000,0.1111,0.1111,0.2222,0.0000,0.0000,0
..
There are 360 rows in total.
I am new to Pandas and cannot figure out how to achieve this. I tried converting pandas to numpy array, to list and tried printing with print(data, end='')
but none worked for me.
Solved:
If any one comes across similar problem ,
solved using df_to_csv
and sys.stdout
:
df.to_csv(sys.stdout, header=False, index=False, float_format='%.4f')