I'm playin around with python
for a couple days, so I'm new all new to the game, please be gentle to me.
I'm trying to read a certain line from a csv
file and after reading it I'm trying to separate
and transpose
it.
Heres what I do:
df1 = pd.read_csv('api_plant.csv', skiprows=1, nrows=1, sep=" [,]", engine='python')
data,"[[1614556800000, 1149], [1614643200000, 1512.1], [1614729600000, 2133.3], [1614816000000, 485.2], [1614902400000, 3091], [1614988800000, 809], [1615075200000, 1018], [1615161600000, 3232.5], [1615248000000, 1709.3], [1615334400000, 2073.5], [1615420800000, 869.2], [1615507200000, 1679.5], [1615593600000, 787.3], [1615680000000, 1509.7], [1615766400000, 1047.6], [1615852800000, 2326.5], [1615939200000, 1444.8], [1616025600000, None], [1616112000000, None], [1616198400000, None], [1616284800000, None], [1616371200000, None], [1616457600000, None], [1616544000000, None], [1616630400000, None], [1616716800000, None], [1616803200000, None], [1616889600000, None], [1616976000000, None], [1617062400000, None], [1617148800000, None]]"
0 date,2021-03-01
df1 = df1.drop([0])
df1 = df1.T
df1 = df1.replace('data', '')
df1 = df1.replace('[', '')
df1 = df1.replace(']', '')
df1 = df1.replace([',', ''])
df1 = df1.replace(['.', ','])
What I get back is almost exactly the same thing I read in, still in only one :
Index: [data,"[[1614556800000, 1149], [1614643200000, 1512.1], [1614729600000, 2133.3], [1614816000000, 485.2], ....
I tried to seperate it by delimiter but that didn't seem to work as well. After that I also wanna get rid of the first number in the square brackets, but that I will try myself first.
Hope my problem is clear and anybody has a quick tip for me.
Thanks guys!