I'm having trouble merging a DataFrames array into one DataFrame merged into a specific column.
I have a list of DataFrames called data , each data[i] element looks like this:
Rank Name 2400 1 name1 2401 2 name2 2402 3 name3 2403 4 name4 2404 5 name5
Each DataFrame contains a Top 5 list for a given month, and the list contains monthly results for the year.
I would like the final merged DataFrame to look like this:
Rank Name_month1 Name_month2 Name_month3 ... 2400 1 name1 name1 name1 ... 2401 2 name2 name2 name2 ... 2402 3 name3 name3 name3 ... 2403 4 name4 name4 name4 ... 2404 5 name5 name5 name5 ...
where each column, after the first, corresponds to a monthly rank.
I have no problem combining 2 DataFrames from a list, data :
pandas.merge(data[0], data[1], on='Rank', suffix=['_month1', '_month2'])
But when I try to use filter() or the .merge chain, I have problems all the time.
Any thoughts? Thanks!
source share