相关疑难解决方法(0)

使用 numpy.mean 分组

我如何计算以下每个 workerid 的平均值?下面是我的示例 NumPy ndarray。第 0 列是 workerid,第 1 列是纬度,第 2 列是经度。
我想计算每个工人的平均纬度和经度。我想使用 NumPy (ndarray) 保留这一切,而不转换为 Pandas。

import numpy
from scipy.spatial.distance import cdist, euclidean
import itertools
from itertools import groupby

class WorkerPatientScores:

    '''
    I read from the Patient and Worker tables in SchedulingOptimization.
    '''
    def __init__(self, dist_weight=1):
        self.a = []

        self.a = ([[25302, 32.133598100000000, -94.395845200000000],
                   [25302, 32.145095132560200, -94.358041585705600],
                   [25302, 32.160400000000000, -94.330700000000000],
                   [25305, 32.133598100000000, -94.395845200000000],
                   [25305, 32.115095132560200, -94.358041585705600],
                   [25305, 32.110400000000000, -94.330700000000000],
                   [25326, 32.123598100000000, -94.395845200000000],
                   [25326, 32.125095132560200, -94.358041585705600],
                   [25326, 32.120400000000000, -94.330700000000000],
                   [25341, …
Run Code Online (Sandbox Code Playgroud)

python arrays group-by numpy numpy-ndarray

2
推荐指数
2
解决办法
5703
查看次数

标签 统计

arrays ×1

group-by ×1

numpy ×1

numpy-ndarray ×1

python ×1