I've got a dataframe,
df = pd.DataFrame([{'project': 123456, 'date': '08/07/2019', 'total': 123,
'count': 12}, {'project': 123457, 'date': '08/07/2019',
'total': 124, 'count': 13}, {'project': 123458, 'date':
'08/07/2019', 'total': 125, 'count': 14}])
I'd like to add a total row to the bottom of only the total and count columns. I know I can do
df.loc['Total'] = df.sum(numeric_only=True)
But my project column is numeric and I do not want the word Total at the bottom row, only the sums for those two columns. Is there any way to remove the word and ensure that only those two columns get summed?
df.loc[len(df)] = df.sum(numeric_only=True)projectcolumn getting summed? Since it's numeric as well.df[cols_to_add].sum()wherecols_to_add = ['col1', 'col2', ...] etc