0

I can not load my csv with pandas correctly, I have some matrices and vectors but I get a (\ r \ n) for example i tried this:

test = pd.read_csv('test.csv',sep='\t',index_col=0)
test.head()

and i get this:

test['image_gray'][0]

'[[0.4297102 0.4297102 0.42578863 ... 0.37573176 0.34549804 0.30628235]\r\n [0.41794549 0.41402392 0.40618078 ... 0.37573176 0.34549804 0.30628235]\r\n [0.39833765 0.39441608 0.38151255 ... 0.3718102 0.34549804 0.30628235]\r\n ...\r\n [0.03164039 0.01987569 0.01763569 ... 0.55161137 0.55553294 0.55496745]\r\n [0.03385765 0.02771882 0.01763569 ... 0.55945451 0.56281059 0.56281059]\r\n [0.03777922 0.02771882 0.01763569 ... 0.56281059 0.56673216 0.57065373]]'

i don't want (\r\n) i have the same proble in others columns of my dataframe.

¿What could i do ?

1 Answers1

0

If you're using windows. then try passing the os.linesep as the lineterminator to read_csv

pd.read_csv('test.csv', sep='\t', sep='\t', lineterminator=os.linesep)

But the file you have might be malformed with \r\n\n. Check that.

rdas
  • 20,604
  • 6
  • 33
  • 46
  • this gives me an error: InvalidConfigError: Invalid client secrets file ('Error opening file', 'client_secrets.json', 'No such file or directory', 2) I created the initial dataframe and it was correct, and i save it with this code: >>dataframeall.to_csv("path//test.csv", sep='\t') – daniel alejandro Gualterosgual May 24 '19 at 16:32