创建时间分组列表

I have X and Y data, where one represents the other respectively, example y [0] = x [0], and a script that divided this data into 5 categories: low, medium, high, ultra and critical and calculates the existing midpoint in the (sum (category) / len (category) if len (category) else 0) categories, thus generating a histogram, I would like to take this data in a performance way, where my Y was divided into lists in the interval of 1 hour (60 data) following the principle that each data corresponds to the time of 1 minute, and from these lists divided in the period of 1 hour the categories low, medium, high were created , ultra and critical and midpoints of each, so there would be the following:

每隔1小时按低频分组的分组,   中,高,超和关键   中点。

以目前的方式,他是否在不造成时间差异的情况下整体计算了任何建议?

数据:

Y = [68 68 69 68 69 70 71 75 72 73 72 72 73 72 72 73 70 71 73 72 72 71 69 68
 69 68 69 68 69 68 68 68 68 69 68 69 70 71 75 72 69 68 68 68 69 68 69 70
 71 75 72 69 68 69 68 69 68 69 68 68 60 60 61 60 61 65 69 69 72 73 72 72
 73 72 72 73 70 71 73 75 78 80 82 84 87 84 84 83 82 79 78 76 74 73 72 72
 72 71 75 72 69 68 68 68 69 68 69 70 71 75 72 69 68 69 68 69 68 69 68 68]

X =  ['2020-01-01 09:00:01' '2020-01-01 09:01:01' '2020-01-01 09:02:01'
 '2020-01-01 09:03:01' '2020-01-01 09:04:01' '2020-01-01 09:05:01'
 '2020-01-01 09:06:01' '2020-01-01 09:07:01' '2020-01-01 09:08:01'
 '2020-01-01 09:09:01' '2020-01-01 09:10:01' '2020-01-01 09:11:01'
 '2020-01-01 09:12:01' '2020-01-01 09:13:01' '2020-01-01 09:14:01'
 ...
 '2020-01-02 09:45:01' '2020-01-02 09:46:01' '2020-01-02 09:47:01'
 '2020-01-02 09:48:01' '2020-01-02 09:49:01' '2020-01-02 09:50:01'
 '2020-01-02 09:51:01' '2020-01-02 09:52:01' '2020-01-02 09:53:01'
 '2020-01-02 09:54:01' '2020-01-02 09:55:01' '2020-01-02 09:56:01'
 '2020-01-02 09:57:01' '2020-01-02 09:58:01' '2020-01-02 09:59:01']

实际:

    Low = []
    Medium = []
    High = []
    Ultra = []
    Critical = []

    for val in Y:
        if val <= 59:
            Low.append(val)
        if val >= 60 and val <= 69:
            Medium.append(val)
        if val >= 70 and val <=79:
            High.append(val)
        if val >= 80 and val <=89:
            Ultra.append(val)
        if val >= 90:
            Critical.append(val)

    pmLow = sum(Low) / len(Low) if len(Low) else 0
    pmMedium =  sum(Medium) / len(Medium) if len(Medium) else 0
    pmHigh =  sum(High) / len(High) if len(High) else 0
    pmUltra =  sum(Ultra) / len(Ultra) if len(Ultra) else 0
    pmCritical =  sum(Critical) / len(Critical) if len(Critical) else 0

    sizeLow = len(Low)
    sizeMedium = len(Medium)
    sizeHigh =  len(High)
    sizeUltra =  len(Ultra)
    sizeCritical =  len(Critical)

axisX.append(pmLow,pmMedium,pmHigh,pmUltra,pmCritical)

axisY.append(sizeLow,sizeMedium,sizeHigh,sizeUltra,sizeCritical)