How to export Pandas DataFrame into CSV file and read it from a string below?
series: [{
name: 'Water',
data: [[90, 50000],[91, 53000],[92, 56000],[93, 62000],[94, 68000],[95, 76000],[96, 83000],[97, 91000],[98, 98000],[99, 105000],[100, 110000],[101, 114000],[102, 116000],[103, 116000],[104, 114000],[105, 111000],[106, 105000],[107, 99000],[108, 92000],[109, 84000],[110, 77000],[111, 69000],[112, 62000],[113, 56000],[114, 52000],[115, 48000],[116, 46000],[117, 45000],[118, 46000],[119, 47000],[120, 48000],[121, 50000],[122, 52000],[123, 54000],[124, 55000],[125, 54000],[126, 53000],[127, 51000],[128, 47000],[129, 43000],[130, 38000]]
},{
name: 'tea',
data: [[90, 47000],[91, 53000],[92, 57000],[93, 59000],[94, 59000],[95, 58000],[96, 55000],[97, 53000],[98, 51000],[99, 51000],[100, 53000],[101, 58000],[102, 64000],[103, 72000],[104, 80000],[105, 89000],[106, 97000],[107, 102000],[108, 105000],[109, 105000],[110, 101000],[111, 95000],[112, 87000],[113, 77000],[114, 67000],[115, 57000],[116, 50000],[117, 46000],[118, 45000],[119, 47000],[120, 53000],[121, 61000],[122, 70000],[123, 81000],[124, 90000],[125, 98000],[126, 103000],[127, 105000],[128, 104000],[129, 100000],[130, 94000]]
},{
name: 'Tonic',
data: [[90, 63000],[91, 68000],[92, 73000],[93, 78000],[94, 82000],[95, 85000],[96, 86000],[97, 86000],[98, 84000],[99, 81000],[100, 77000],[101, 71000],[102, 66000],[103, 60000],[104, 54000],[105, 50000],[106, 46000],[107, 44000],[108, 44000],[109, 46000],[110, 49000],[111, 54000],[112, 60000],[113, 67000],[114, 74000],[115, 81000],[116, 88000],[117, 94000],[118, 99000],[119, 102000],[120, 104000],[121, 104000],[122, 102000],[123, 99000],[124, 95000],[125, 91000],[126, 86000],[127, 81000],[128, 77000],[129, 74000],[130, 72000]]
}]
This is my code:
newdata = eval(string)
df = pd.DataFrame(newdata)
df.to_csv('filename.csv', index=False)
print(df)
This is the desired output from to_csv
call: