I have the following (simplified) dataframe:
df = pd.DataFrame({\'X\': [1, 2, 3, 4, 5,6,7,8,9,10], \'Y\': [10,20,30,40,50,-10,-20,-30,-40,-50], \'Z\': [20,18
You can use apply with nsmallest:
apply
n = 3 df.apply(lambda x: pd.Series(x.nsmallest(n).index)) # X Y Z #0 A J J #1 B I I #2 C H H