数据框包含
>> df
A B C
A
196512 196512 1325 12.9010511000000
196512 196512 114569 12.9267705000000
196512 196512 118910 12.8983353775637
196512 196512 100688 12.9505091000000
196795 196795 28978 12.7805170314276
196795 196795 34591 12.8994111000000
196795 196795 13078 12.9135746000000
196795 196795 24173 12.8769653100000
196341 196341 118910 12.8983353775637
196341 196341 100688 12.9505091000000
196641 196641 28972 12.7805170314276
196641 196641 34591 12.8994111000000
196346 196341 118910 12.8983353775637
196346 196341 100688 12.9505091000000
196646 196641 28980 12.7805170314276
196646 196641 34591 12.8994111000000
我尝试获取每个组的最小值并使用以下代码显示,
df.columns = ['a','b','c']
df.index = df.a.astype(str)
dd=df.groupby('a').min()['c']
它给出了结果
196512 12.7805170314276
196795 12.7805170314276
196341 12.7805170314276
196346 12.7805170314276
但分组后,我想获得具有最小“c”值的行,按“a”列分组,并在结果中显示完整匹配的行,例如,
196512 118910 12.8983353775637
196795 28978 12.7805170314276
196341 28972 12.7805170314276
196346 28980 12.7805170314276