I want to flatten a dataframe in pandas. This is basically by duplicating the column_names with prefix/suffix of occurence/order of the column and the number of extra columns created should be based on the number of rows.
For example:
`
df = pd.DataFrame({
'id': [1, 2, 3, 4],
'A': [10, 20, 30, 40],
'B': [50, 60, 70, 80],
'C': [90, 100, 110, 120]
})
print(df)
# id A B C
# 0 1 10 50 90
# 1 2 20 60 100
# 2 3 30 70 110
# 3 4 40 80 120
#I want something like the following.
print(result_df)
# id1 A1 B1 C1 id2 A2 B2 C2 id3 A3 B3 C3 id4 A4 B4 C4
# 0 1 10 50 90 2 20 60 100 3 30 70 110 4 40 80 120
`