0

I want to take each row in my pandas dataframe and print it out. Here's what I got so far. I want 3 decimal places to columns, x, y, z.

import pandas as pd
data = pd.read_csv('2atoms.csv')
outF= open("firsttxt.txt", "w")
df = pd.DataFrame(data, columns = ['index','x','y','z'])
pd.options.display.float_format = '{:.2f}'.format
for line in df:
    outF.write(data)
    outF.write("\n")
outF.close()

I thought that outF command would work but it is only for string...what else can be used?

0 Answers0