Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/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
Python 从数组列表中的每个数组中获取元素?_Python - Fatal编程技术网

Python 从数组列表中的每个数组中获取元素?

Python 从数组列表中的每个数组中获取元素?,python,Python,我有一个数组列表,如下所示: [array([ 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.04347826, 3.0434782

我有一个数组列表,如下所示:

[array([ 3.04347826,  3.04347826,  3.04347826,  3.04347826,  3.04347826,
    3.04347826,  3.04347826,  3.04347826,  3.04347826,  3.04347826,
    3.04347826,  3.04347826,  3.04347826,  3.04347826,  3.04347826,
    3.04347826,  3.04347826,  3.04347826,  3.04347826,  3.04347826,
    3.04347826,  3.04347826,  3.04347826]), array([ 3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,
    3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,
    3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,  3.5,
    3.5,  3.5,  3.5,  3.5,  3.5]), array([ 3.08823529,  3.08823529,  3.08823529,  3.08823529,  3.08823529,
    3.08823529,  3.08823529,  3.08823529,  3.08823529,  3.08823529,
    3.08823529,  3.08823529,  3.08823529,  3.08823529,  3.08823529,
    3.08823529,  3.08823529,  3.08823529,  3.08823529,  3.08823529,
    3.08823529,  3.08823529,  3.08823529,  3.08823529,  3.08823529,
    3.08823529,  3.08823529,  3.08823529,  3.08823529,  3.08823529,
    3.08823529,  3.08823529,  3.08823529,  3.08823529]), array([ 3.84848485,  3.84848485,  3.84848485,  3.84848485,  3.84848485,
    3.84848485,  3.84848485,  3.84848485,  3.84848485,  3.84848485,
    3.84848485,  3.84848485,  3.84848485,  3.84848485,  3.84848485,
    3.84848485,  3.84848485,  3.84848485,  3.84848485,  3.84848485,
    3.84848485,  3.84848485,  3.84848485,  3.8484848....

如何仅获取每个数组的第一个元素?

假设数组是一个
numpy.array

first_elements = [e[0] for e in list1]
其中:

list1
是您的数组列表

first\u elements
是一个列表,其中包含
list1

以更明确的方式:

first_elements = []
for arr in list1:
    first_elements.append(arr[0])

假设数组是
numpy.array

first_elements = [e[0] for e in list1]
其中:

list1
是您的数组列表

first\u elements
是一个列表,其中包含
list1

以更明确的方式:

first_elements = []
for arr in list1:
    first_elements.append(arr[0])