I've got a set of dataframes that through lots of fiddling have comments and flags on whether or not the data is good:
df = pd.DataFrame({'Name': ['a','a','b','b'],
'Measurements': ['temp','pressure','temp','pressure'],
'Values': [1, 2, -1, np.nan],
'Comment': ['','','Is negative', 'Is NaN'],
'IsBad':[False, False, True, True] })
measurements = df.reset_index().pivot(index='Name',columns='Measurements',values='Values')
comments = df.reset_index().pivot(index='Name',columns='Measurements',values='Comment')
bad_cells = df.reset_index().pivot(index='Name',columns='Measurements',values='IsBad')
What I'd like to do is export this to an excel file that has the cells formatted by "IsBad" and a comment stuck in to explain why the cell is bad (ignore that this example starts at A2...):
I've been looking at a couple different ways to do this and I'm stuck, I can create an excel file with a new sheet for each pivoted dataframe but I can't seem to create comments using other sheets as an input. XlsxWriter also seems to not be too great at creating an excel file in a loop where I could define each cell based on rows in the "df" object.
Any ideas?