Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19999

Dataframe list to array comma delimited by value and semicolon delimited by line

$
0
0

I am trying to convert dataframe back to array. I started with array as follows

1.0,2.0,1.0,4.0;2.0,3.0,1.0,2.0;1.0,4.0,6.0,3.0

I convert to dataframe with

with open('PV.csv','r') as f:    array = [l.split(",") for l in f.readline().split(";") if l]

which gives

1.0 2.0 1.0 4.02.0 3.0 1.0 2.01.0 4.0 6.0 3.0

The data is saved as a CSV which looks like this when opened with excel

enter image description here

I am trying to use join to put it back together in the CSV file but I can't work out how to split the values by comma and the lines by semicolon as original.


Viewing all articles
Browse latest Browse all 19999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>