I am trying to split and merge a Pandas dataframe.
The columns of the original data frame are arranged like so:
dataTime Record1Field1 ... Record1FieldN Record2Field1 ... Record1FieldN
time1 << record 1 data >> << record 2 data >>
I would like to take split the Record2 fields into a separate data frame tempdf, indexed by the dataTime. tempdf will therefore look something like this:
dataTime Record2Field1 ... Record2FieldN
time1 << record 2 data >>
Once tempdf is populated, delete the Record2 columns from the original data frame. The first difficulty I'm having is in creating this tempdf which contains the record 2 data.
Then, I would like to rename the columns in tempdf so that they align with the Record1 columns in the original data frame. (This portion I know how to do)
Finally I would like to merge tempdf back into the original data frame.
The end result should look something like this:
dataTime Record1Field1 ... Record1FieldN
time1 <<record 1 data>>
time1 <<record 2 data>>
So far I haven't determined a good method of doing this. Any help is appreciated! Thanks.
merge?concatorappendtempdfdata frame which contains all of the record 2 data.Record2Field..form a continuous sequence as in range from 1→N?