[英]Splitting a python data frame on column names
I have a python data frame in the format below我有以下格式的python数据框
Timestamp1 Column1 Column2 Column3 Timestamp2 Column4 Column5 Column6 Column 7
01-01-2018 5.0 4.7 5.1 01-01-2018 5.8 7.9 6.7 8.1
01-02-2018 5.4 2.7 3.1 01-02-2018 1.8 1.9 2.7 8.1
I want to split it into two data frames such that I have two data frames like我想把它分成两个数据框,这样我就有两个数据框,比如
Timestamp1 Column1 Column2 Column3
01-01-2018 5.0 4.7 5.1
01-02-2018 5.4 2.7 3.1
Timestamp2 Column4 Column5 Column6 Column7
01-01-2018 5.8 7.9 6.7 8.1
01-02-2018 1.8 1.9 2.7 8.1
I tried to groupby, but was not able to get it to work.我试图分组,但无法让它工作。 Column names can be different, so I am looking to split on the Timestamp and create two DF's
列名可以不同,所以我希望在时间戳上拆分并创建两个 DF
Any inputs on what I can use to achieve this?关于我可以用来实现这一目标的任何输入? Thanks!
谢谢!
做df1 = df.loc[:,'Timestamp1':'Column3']
和df2 = df.loc[:,'Timestamp2':'Column7']
应该给你想要的结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.