Convert SList to Dataframe

限于喜欢 提交于 2020-06-26 03:57:07

问题


I am reading data from a binary .out file using a python module "SWMMToolbox." The command to read the infilration time series for RG1 from the file.out is as follows:

x = !swmmtoolbox extract 'file.out' subcatchment,RG1,Infiltration_loss

See link for details about swmmtoolbox.

The data type of 'x' is a 'IPython.utils.text.SList' The data looks like this:

I would like to import this Slist into pandas, but am having trouble. I want to get the datetime string as one column and the value after the comma as another. However, when I use

df = pd.DataFrame(data=x)

I get the following:

I also tried to use

df = pd.DataFrame.from_records(x)

but get this:

I tried to use pd.read_csv, but I couldn't get it to work since 'x' is a variable and not a file.

Any suggestions are much appreciated.

来源:https://stackoverflow.com/questions/51713714/convert-slist-to-dataframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!