0

Hello I generated a dataframe df that looks like the following

enter image description here

Where car, time and val array arrays. I saved this dataframe as

df.to_csv('MyData/data.csv')

However when I upload it the columns car, time and val are strings. Is there any way to keep the columns as arrays?

emax
  • 6,965
  • 19
  • 74
  • 141
  • Can you show what the first few lines of the output looks like, and how you would like it to look? – Jezzamon Feb 04 '16 at 21:22
  • I think you're going to run into issues due to the file format. It's a CSV, so if any field has commas then you have enclose it in quotes. If it didn't do this, there would be no way of distinguishing two separate columns and one with commas it in – Jezzamon Feb 04 '16 at 21:25
  • When I upload the file, the entry is like `df.val[0] = '[ 14.50980392 14.11764706 14.50980392 ..., 14.50980392 14.11764706\n 14.50980392]'` which is a string of `char` and I would like `df.val[0]= array([ 14.50980392, 14.11764706, 14.50980392, ..., 14.50980392, 14.11764706, 14.50980392])` as in the original table – emax Feb 04 '16 at 21:53
  • Could you please edit the question to include this information? – Jezzamon Feb 04 '16 at 22:03
  • If you just want to save the data frame so you can load it again, you would be better saving it to a different format. Have a look here: http://stackoverflow.com/questions/17098654/how-to-store-data-frame-using-pandas-python – Jezzamon Feb 04 '16 at 22:09
  • If it has to be a csv, the issue here isn't the saving, but how the file is being parsed when it's read (this is what you mean by 'upload', right?). In this case, I think this may help. http://stackoverflow.com/questions/23119472/in-pandas-python-reading-array-stored-as-string?rq=1 – Jezzamon Feb 04 '16 at 22:14
  • It has not be a `.csv`. You solved my issue! – emax Feb 04 '16 at 22:47

0 Answers0