[Python] np.asarray not allowing strings

Discussão em 'Python' iniciado por Stack, Junho 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following df[​IMG]

    I am trying to measure the distances/similarities between certain rows.

    import gower
    distances = data_test_prepared.iloc[: , 2:]
    X = np.asarray(distances)
    Y = np.asarray(data_test_prepared)
    gower.gower_matrix(X)


    However, when I run this, I get an error saying:

    ValueError: could not convert string to float: 'Malay'


    I thought np.asarray could accept strings, so I do not know what is wrong here.

    Continue reading...

Compartilhe esta Página