Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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 多索引数据帧数据提取_Python_Python 3.x_Pandas - Fatal编程技术网

Python 多索引数据帧数据提取

Python 多索引数据帧数据提取,python,python-3.x,pandas,Python,Python 3.x,Pandas,我有一个pandas数据框,其中第一行有多个条目,但第二行有重复列 A B. C Date High Low High Low. High Low 2000-07-03 19.796038 19.202157 9.261945 9

我有一个pandas数据框,其中第一行有多个条目,但第二行有重复列

                   A                           B.                     C
Date           High         Low            High       Low.        High        Low       
2000-07-03     19.796038    19.202157      9.261945   9.011265    19.261945   9.011265

2000-07-05     19.845534    18.845534      9.81945    8.011       29.81945    8.011
我想找出哪个A、B或C在日期的高低上有最大的区别

Desired output:
                     C
         Date        High          Low      Difference 
         2000-07-05  29.81945      8.011.   21.808
哪一个更好的透视表、分组、熔化?

我们可以做堆栈,然后是idxmax

我们可以做堆栈,然后是idxmax

s=df.stack(level=0)
idx=(s['High']-s['Low']).idxmax()

df.loc[[idx[0]],[idx[1]]]
Out[268]: 
                   C       
                High    Low
Date                       
2000-07-05  29.81945  8.011