Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:访问panda系列的值_Python_Pandas_Series_Pandas Groupby - Fatal编程技术网

Python:访问panda系列的值

Python:访问panda系列的值,python,pandas,series,pandas-groupby,Python,Pandas,Series,Pandas Groupby,我将一个数据帧分为两列,并计算每组的分位数。因此,该系列现在看起来像这样: Group vehicle 1 car 5.6 bike 34.0 2 car 7.0 bike 40.0 在下一步中,我需要检查值是否低于分位数,如果是,请采取措施。为此,我需要访问组和车辆的特定值(系列第3列) 综上所述,我如何通过组和车辆获取值34.0?仅通过元组选择: val = s.loc[(1, 'b

我将一个数据帧分为两列,并计算每组的分位数。因此,该系列现在看起来像这样:

Group   vehicle
1       car        5.6
        bike      34.0
2       car        7.0
        bike      40.0
在下一步中,我需要检查值是否低于分位数,如果是,请采取措施。为此,我需要访问
车辆
的特定值(系列第3列)


综上所述,我如何通过
车辆
获取值
34.0

仅通过
元组选择:

val = s.loc[(1, 'bike')]
print (val)
34.0
如果需要,仅通过第一级或第二级选择使用:

s1 = s.xs(1)
print (s1)
vehicle
car      5.6
bike    34.0
Name: a, dtype: float64

s2 = s.xs('bike', level=1)
print (s2)
Group
1    34.0
2    40.0
Name: a, dtype: float6