Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.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,我有一个pandasDataFrame,我正在寻找其中的最小值 print(df.loc[df['Price'].idxmin()]) 它正在工作,我可以打印整个“行”,结果如下: Country Switzerland City Zurich Airport Zurich Carrier Vueling Airlines Type

我有一个pandas
DataFrame
,我正在寻找其中的最小值

print(df.loc[df['Price'].idxmin()])
它正在工作,我可以打印整个“行”,结果如下:

Country              Switzerland
City                      Zurich
Airport                   Zurich
Carrier         Vueling Airlines
Type                      Direct
Date         2017-09-05T00:00:00
Price                      12360
AirportId                    ZRH
Name: 97, dtype: object

Process finished with exit code 0
例如,如何仅打印
AirportId


谢谢大家!

通过对其进行过滤:

print(df.loc[df['Price'].idxmin()]['Airport'])
如果要将数据写入该单元格,请继续使用
loc

df.loc[df['Price'].idxmin(),'Airport']

假设这是您的数据帧:

your_df = pd.DataFrame(data={'Airport':['x','y','z'], 'type': ['A','B','C'],
      'price':[5450, 5450, 15998]})
您可以按如下方式访问第一列:

print your_df.loc[your_df['price'].idxmin()].values[0]

从技术上讲,链接索引,
print(df.loc[df['Price'].idxmin(),'Airport'])
比IMO+1更好,不过你太棒了!:)谢谢大家!@EdChum faire足以得到R/W情况下更明确的变化。编辑,谢谢!