Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.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
TypeError:在python中尝试按行获取两列的最小值时出现无效键错误_Python_Excel_Pandas - Fatal编程技术网

TypeError:在python中尝试按行获取两列的最小值时出现无效键错误

TypeError:在python中尝试按行获取两列的最小值时出现无效键错误,python,excel,pandas,Python,Excel,Pandas,GettingTypeError:“(['Guardars'],['order_case'])是无效键”尝试在pandas中按行获取至少两列时出错,但上述两列存在于数据框中 代码行: Master_文件['guarders View']=min(Master_文件['guarders'],['order_case']])从数据框中选择多列的正确语法是df[[column1,column2]。此外,由于您正试图获取两列中的行最小值,因此需要使用with参数axis=1(执行行操作的是axis=1参

Getting
TypeError:“(['Guardars'],['order_case'])是无效键”
尝试在pandas中按行获取至少两列时出错,但上述两列存在于数据框中

代码行:


Master_文件['guarders View']=min(Master_文件['guarders'],['order_case']])
从数据框中选择多列的正确语法是
df[[column1,column2]
。此外,由于您正试图获取两列中的行最小值,因此需要使用with参数
axis=1
(执行行操作的是
axis=1
参数;默认行为为列)。因此,在您的情况下,代码是:

Master_File['Guardrails View'] = Master_File[['guardrails','order_case']].min(axis=1)
它将
护栏视图
列附加到
主文件
数据框,该列包含
护栏
订单案例
的行最小值