Creating a Running Total Column in Pandas

Python
Data Preprocessing

Creates a column in the orders DataFrame that contains a running total for each ProductID over time.

 1|  orders.sort_values(by=['Order_Date'], inplace=True)
 2|  orders['running_total'] = orders.groupby(['ProductID'],as_index=False)['units'].cumsum()
3 Upvotes
Tags: Pandas
Did you find this snippet useful?

Sign up to bookmark this in your snippet library

Normalize Windowed Time Series
Python
Data Preprocessing

Scaler | Normalize | Scale | Min-max

4
Pivoting Pandas Dataframes
Python
Data Preprocessing

Pandas

3
2