I have a dataframe data_df
with n
rows:
Rank DutyCode
200 ABC
300 DEF
400 GHI
Then, I want to iteratively join them as one row, example:
Rank DutyCode Rank_1 DutyCode_1 Rank_2 DutyCode_2
200 ABC 300 DEF 400 GHI
My current code :
column_data_df = data_df.iloc[[1]]
data_df.iloc = data_df.iloc.drop([0])
data_df = data_df.join(column_data_df, rsuffix='_1')
and only produce :
Rank DutyCode Rank_1 DutyCode_1
200 ABC 300 DEF
This only works for one time.. I want it to be dynamic for n
number of rows.
EDIT
Another dataframe :
Rank DutyCode
{'a':'b', 'i':'j'} ABC
{'a':'b', 'i':'j'} DEF
{'a':'b', 'i':'j'} GHI
To :
Rank.a Rank.i DutyCode Rank_1.a Rank_1.i DutyCode_1
b j ABC b j DEF
I hope this makes sense..