I have a df that has repeating ids:
code_contract days_may19
1 8
2 9
3 7
1 8
2 9
3 7
1 8
2 9
3 7
I want to add a df 'jun19' but it has only code contract ids 1,2,3 matching with df above:
code_contract days_jun_19
1 9
2 6
3 56
4 34
5 12
the end result should be :
code_contract days_may19 days_jun19
1 8 9
2 9 6
3 7 56
1 8 9
2 9 6
3 7 56
1 8 9
2 9 6
3 7 56
how to join them?
my code - this final report has 89420 rows, 5 months under each other, each month is 17884*5 = 89420. each code_contract is repeating in every month, i need to have this df of repeating ids. I have another df 'jun19'.
df jun19 has 17884 rows, contract ids, it has one column 'max days as per jun19'. that is the column I 'm trying to add.
the problem is this column getting mapped only to the first 17884 rows, and all other ~71k rows is getting nans instead of same values.
final_report = pd.concat([jan19, feb19, march19, april19, may19], axis=0,ignore_index=True)
col_exp = final_report.filter(like='Макс').columns
final_report[col_exp] = final_report.groupby('code_contract')[col_exp].transform('first')
the code:
final_report = pd.concat([final_report, jun19], axis=1)