Note

Pandas (52) 본문

Pandas

Pandas (52)

알 수 없는 사용자 2022. 9. 21. 01:05
728x90

How to find the position of the nth largest value greater than a given value?

# Input
ser = pd.Series(np.random.randint(1, 100, 15))

# Solution
print('ser: ', ser.tolist(), 'mean: ', round(ser.mean()))
np.argwhere(ser > ser.mean())[1]

# output 1
ser:  [7, 77, 16, 86, 60, 38, 34, 36, 83, 27, 16, 52, 50, 52, 54] mean:  46
# output 2
array([3])

'Pandas' 카테고리의 다른 글

Pandas (55)  (0) 2022.10.14
Pandas (54)  (0) 2022.10.13
Pandas (53)  (0) 2022.09.20
Pandas (51)  (1) 2022.09.17
Pandas (50)  (0) 2022.09.16
Comments