Skip to content
Advertisement

Tag: cumsum

pandas cumsum on lag-differenced dataframe

Say I have a pd.DataFrame() that I differenced with .diff(5), which works like “new number at idx i = (number at idx i) – (number at idx i-5)” Now I want to undo this operation using the first 5 entries of example_df, and using df_diff. If i had done .diff(1), I would simply use .cumsum(). But how can I achieve

Pandas cumsum with keys

I have two DataFrames (first, second): index_first value_1 value_2 0 100 1 1 200 2 2 300 3 index_second value_1 value_2 0 50 10 1 100 20 2 150 30 Next I concat the two DataFrames with keys: My goal is to calculate the cumulative sum of value_1 and value_2 in z considering the keys. So the final DataFrame should

Advertisement