如何在元组中选择数组的第n个元素?

时间:2017-10-26 02:07:05

标签: python numpy

我有这样的元组:

  

(array([0,0,0]),array([0,1,2]))

我想在这个元组中选择每个数组的第一个元素,并希望实现这个结果: [0,0]或[0,1]或[0,2]

我该怎么做?

实际上,这个元组是从numpy.where中的函数获得的 我做的是这样的:

  

将numpy导入为np

     

X = np.array([[1,2,3],[4,5,6],[7,8,9]])

     

XI = np.where(X LT; 4)

任何建议?

2 个答案:

答案 0 :(得分:0)

这是你想要的吗?

    NEVPNProtocolIPSec *p = [[NEVPNProtocolIPSec alloc] init];
    p.username = [config objectForKey: @"username"];
    p.passwordReference = [config objectForKey: @"password"];
    p.serverAddress = [config objectForKey: @"ip"];
    p.localIdentifier = [config objectForKey: @"vpn"];
    p.remoteIdentifier = [config objectForKey: @"vpn"];
    p.useExtendedAuthentication = NO;
    p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;   
    p.disconnectOnSleep = NO;

    p.sharedSecretReference = [config objectForKey: @"psk"];

数据输入

list(zip(tp[0],tp[1]))
Out[689]: [(0, 0), (0, 1), (0, 2)]

如果要列出清单

tp=(np.array([0, 0, 0]), np.array([0, 1, 2]))

答案 1 :(得分:0)

您可以通过<local:IconImage Icon="Shutdown" Colour="CornflowerBlue" /> 遍历numpy数组并将它们配对:

nditer
相关问题