Python to sum values in a column I've created a Python code that reads the data from an excel file using Pandas.

Code for your reference:-

import pandas as pd

def myFunc():
   file = r"C:\Documents\myFile.xlsx"
   new_dataframe = pd.read_excel(file,'Sheet1')
   new_dataframe.fillna(value="No Data Found",inplace=True)
   print new_dataframe

myFunc


Current Output:-

             Name        date    amount_used
0             P1   2018-07-01          40.0
1             P1   2018-07-01          40.0
2             P1   2018-07-15          40.0
3             P2   2018-08-01          20.0
4             P2   2018-09-15          50.0
5             P2   2018-08-15          40.0
6             P3   2018-08-10          20.0
7             P3   2018-08-10          50.0
8             P3   2018-08-10          40.0


In the final output, I need to sum the amount_used column based on Name and date column.

Expected Output:-

             Name        date    amount_used
0             P1   2018-07-01          80.0
1             P1   2018-07-15          40.0
2             P2   2018-07-01          20.0
3             P2   2018-08-15          90.0
4             P3   2018-08-10         110.0


How can I achieve this using pandas ?
You can use groupby and then sum
Take a look at https://stackoverflow.com/questions/39922986/pandas-group-by-and-sum