1
有沒有辦法爲索引One
提取B
的所有值,其中C
大於零?所以我想提取值-0.22
和-1.21
。熊貓中的邏輯多元索引
import numpy as np
import pandas as pd
arrays =[np.array(['One','One','One','Two','Two','Two']),np.array(['A','B','C','A','B','C'])]
df = pd.DataFrame(np.random.randn(6,5),index=arrays)
df
0 1 2 3 4
One A -0.908680 0.031505 -0.087090 -0.039527 0.221196
B 1.010757 1.272553 -0.220535 -1.216996 -0.122108
C -0.781714 -1.830215 0.584311 0.010987 -0.050355
Two A -0.331269 0.410596 0.569802 1.455710 0.377796
B 0.079330 -2.538031 -1.665904 0.477257 0.500805
C -0.388749 2.188289 -1.465292 0.594870 -0.031983