Assuming you have a dataframe df
with a date
column and a value
column, you can use the groupby
function together with diff
to calculate the daily differences:
main.py68 chars2 lines
This will group the dataframe by date, calculate the difference for each group (i.e. each date), and fill NaN values with 0. The daily differences will be stored in a new column called daily_change
.
gistlibby LogSnag