Reputation: 1888
I have a pandas DataFrame that looks like this::
>>> df
In [6]: df
Out[6]:
0 1 2 3
0 0.445598 0.173835 0.343415 0.682252
1 0.881592 0.696942 0.702232 0.696724
2 0.662527 0.955193 0.131016 0.609548
and I'd simply like an ascii output such as:
0 1 2 3
0 0.446 0.174 0.343 0.682
1 0.882 0.697 0.702 0.697
2 0.663 0.955 0.131 0.610
I can use
df = df.round(3)
but then
data.to_ascii
screws up the formatting.
Upvotes: 0
Views: 391
Reputation: 1869
You can use to_string()
.
df = pd.read_clipboard()
print(df.round(3).to_string())
#Output
0 1 2 3
0 0.446 0.174 0.343 0.682
1 0.882 0.697 0.702 0.697
2 0.663 0.955 0.131 0.610
Upvotes: 1