I'm trying to append a pandas DF that should show values with dollar amounts with another DF to show percentage value (division of the dollar values)
DF1:
DF2:
I'm able to format the columns correctly if i keep the DFs separated but it fails when appending, and formats all the column as $ or %.
I'm using the following code, and would like to understand how to define the subset by "Description" column value?
opps[(opps['Name'] == name) & (opps['Description'] != 'Win Rate')].iloc[:,4:].reset_index(drop=True)\
.replace([np.inf, -np.inf], 0, regex=True)\
.append(opps[(opps['Name'] == name) & (opps['Description'] == 'Win Rate')].iloc[:,4:]).reset_index(drop=True)\
.replace([np.inf, -np.inf], 0, regex=True)\
.style\
.set_table_styles(styles)\
.format("{:.0%}", na_rep="-", subset=['YTD#'])
Thanks