Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.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_Arrays_Comparison_Inequality - Fatal编程技术网

如何在python中比较两个数组的不平等性?(例如更大)

如何在python中比较两个数组的不平等性?(例如更大),python,arrays,comparison,inequality,Python,Arrays,Comparison,Inequality,有人知道如何在python中比较两个数组吗?我几乎什么都试过了,但没有成功。有人能帮忙吗? 我的意思是,对于所有元素,一个数组/列表在两个数组的相同形状中都更大 (a=numpy.array([[1,2,3]] b=numpy.array([[4,5,6]]) 那么b比a大不太清楚您的意思,但如果您只是想检查两个数组(在python中称为列表)是否相同,可以这样做: lst_1 = [1,2,3] lst_2 = [1,2,3] if lst_1 == lst_2: print("Th

有人知道如何在python中比较两个数组吗?我几乎什么都试过了,但没有成功。有人能帮忙吗? 我的意思是,对于所有元素,一个数组/列表在两个数组的相同形状中都更大

a=numpy.array([[1,2,3]]
b=numpy.array([[4,5,6]])


那么b比a大

不太清楚您的意思,但如果您只是想检查两个数组(在python中称为列表)是否相同,可以这样做:

lst_1 = [1,2,3]
lst_2 = [1,2,3]

if lst_1 == lst_2:
    print("They were the same!")
else:
    print("They weren't the same!")
arr1 = [1, 2, 3]
arr2 = [2, 3, 4]

count = 0
for i in range(len(arr1)):
    if(arr1[i] < arr2[i]):
        count += 1

if(count == len(arr1)):
    print("Greater for sure")
else:
    print("unsure")

做一个直接的比较是行不通的(而且可能也没有意义)

例如,以下输出为真:

但是,您可以尝试以下方法:

lst_1 = [1,2,3]
lst_2 = [1,2,3]

if lst_1 == lst_2:
    print("They were the same!")
else:
    print("They weren't the same!")
arr1 = [1, 2, 3]
arr2 = [2, 3, 4]

count = 0
for i in range(len(arr1)):
    if(arr1[i] < arr2[i]):
        count += 1

if(count == len(arr1)):
    print("Greater for sure")
else:
    print("unsure")
arr1=[1,2,3]
arr2=[2,3,4]
计数=0
对于范围内的i(len(arr1)):
如果(arr1[i]
那么,一个数组比另一个数组“大”意味着什么呢?你的问题很模糊。你能给我们举个例子,两个输入数组和比较结果吗?为了发布一个人们可以帮助你的问题,你应该包括一些要处理的数据,以及一些“几乎所有的东西”如果您尝试了失败的方法,例如a=[1,2,3],b=[4,5,6],那么b大于a(我的意思是)是的,但我在看是否有现成的函数或库。如果你能将数据转换成熊猫数据帧,那么你可以用这个:如果你想使用numpy路径,那么就用这个:是的,它成功了,谢谢你!