I am using this code to select the smallest row in a column of a given df (got this appraoch from here):
data = pd.DataFrame({'A': [1,1,1,2,2,2], 'B':[4,5,2,7,4,6], 'C':[3,4,10,2,4,6]})
min_value = data.groupby('A').B.min()
data = data.merge(min_value, on='A',suffixes=('', '_min'))
data = data[data.B==data.B_min].drop('B_min', axis=1)
I would like to modify this such that I get the 2nd (or nth) lowest value for that column.