[Python] How can I correct my code gives error for list?

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to write a code with the objective to determine the fixed point of a nonlinear system. The code can determine the fixed points but there exixts few "None" values which when removed, generates varied array length of data. Hence, I tried to use padding. But it generates error which says


    AttributeError: 'numpy.ndarray' object has no attribute 'my_list'
    ​

    The code as below

    g1_fp1_arr = pad_list(g1_fp1_arr.my_list(), max_len)
    g1_fp2_arr = pad_list(g1_fp2_arr.my_list(), max_len)
    g1_mean = pad_list(g1_mean.my_list(), max_len)
    g1_diff = pad_list(g1_diff.my_list(), max_len)
    g2_fp_arr = pad_list(g2_fp_arr.my_list(), max_len)

    def pad_list(lst, length):
    return lst + [np.nan] * (length - len(lst))

    Continue reading...

Compartilhe esta Página