Pandas Groupby Get Values from Previous Group
Given the following: import pandas as pd import numpy as np df = pd.DataFrame({‘a’:[‘a’,’a’,’b’,’b’,’c’,’c’],:[1,1,np.nan,np.nan,1,1]}) df a b 0 a 1.0 1 a 1.0 2 b NaN 3 b NaN 4 c 1.0 5 c 1.0 I need to create a new column ("c") by grouping by "a" and shifting the values of "b" down from… Read More Pandas Groupby Get Values from Previous Group