I have a data-frame called 'df_main'
in which the # of rows changes with every import of a csv from the user. No matter that amount of rows, the row 'salon totals' and column 'Paid_BB_Percent'
will always exist. I would like to copy the data from df_main.loc['salon totals', 'Paid_BB_Percent]
and make a new column on the end of the data-frame called 'Store_BB_Percent'
where every cell in the column contains a copy of this data.
The idea is that I am going to have another data-frame which will contain a row df_manager = df_main[df_main['Employee'].str.contains(manager_name)]
that will be used to find a specific manager row by user input, then a new column will be added like this: df_manager['Manager_BB_Bonus'] = (df_manager['Service_Sales'] - df_manager['Service_Breakpoint']) * (df_manager['Store_BB_Percent']).round(2)
Another, and better way to do this, would be to just multiply df_main.iloc['salon totals', 'Paid_BB_Percent']
by df_manager['Manager_Service_Diff']
like this:
df_manager['Manager_BB_Bonus'] = (df_main.loc['salon totals', 'Paid_BB_Percent'] * df_manager['Manager_Service_Diff'])
The issue with this is when I run:
df_manager = df_main[df_main['Employee'].str.contains(manager_name)]
df_manager['Service_Breakpoint'] = 1700
df_manager['Manager_Service_Diff'] = (df_manager['Service_Sales'] - df_manager['Service_Breakpoint'])
df_manager['Manager_BB_Bonus'] = (df_main.loc['salon totals', 'Paid_BB_Percent'] * df_manager['Manager_Service_Diff'])
df_manager
I get the error: "KeyError: 'the label [salon totals] is not in the [index]'"
Any help is appreciated.