python - pandas: write df to text file - indent df to right by 5 white spaces -
i writing df text file so:
file = open("pptx_comparision_log.txt", "w") df= df.to_string() file.write(comp_df)
this works fine how can indent df sits 5 white spaces right.
so this:
dim_pptx qp_pptx absolute radio 0.0739 0.0753 bbc asian network 0.0013 0.0013 bbc radio 1 0.1441 0.1455 bbc radio 1xtra 0.0057 0.0058 bbc radio 2 0.2336 0.2339
to:
dim_pptx qp_pptx absolute radio 0.0739 0.0753 bbc asian network 0.0013 0.0013 bbc radio 1 0.1441 0.1455 bbc radio 1xtra 0.0057 0.0058 bbc radio 2 0.2336 0.2339
is possible?
thanks.
you can string manipulation after conversion replacing df.to_string()
" "*5 + df.to_string().replace("\n", "\n ")
.
Comments
Post a Comment