I have a dataframe that looks like:
A B C D
0 1.2 0 1.1 3.2
1 2.3 2.2 2.2 2.5
2 1.1 1.5 0 1.7
3 0 1.1 1.4 1.2
4 3.3 3.0 1.7 1.7
5 1.1 1.0 2.2 2.5
6 5.0 5.0 5.0 5.0
I would like to find the frequency that each column contains the row's minimum. So in some format:
B: 2 # rows 0, 5
A: 1 # row 3
C: 1 # row 2
(B, C): 1 # row 1
(C, D): 1 # row 4
(A, B, C, D): 1 # row 6
I am currently doing df.min(axis=1) and then looping through each row using df.iloc... but there has to be a better way.
In case it matters, I have a couple hundred columns, a couple thousand rows, and it represents a sample, so I have to perform the operation roughly a million times. I must be missing an obvious pandas or numpy method that will do this both pythonically and reasonably efficiently.