Create new column by selecting dataframe subset based on current row value and sum another column
Create new column by selecting dataframe subset based on current row value and sum another column Question: Lets say we have a sample dataframe that looks like this # Create a sample dataframe df = pd.DataFrame({‘num_posts’: [4, 6, 3, 9, 1, 14, 2, 5, 7, 2,12], ‘date’ : [‘2020-03-01’, ‘2020-01-02’, ‘2020-01-03’, ‘2020-01-04’, ‘2019-01-05’, ‘2019-01-06’, ‘2020-01-07’, …