[Python] tabpy connections issue [tableau & python]

Discussão em 'Python' iniciado por Stack, Julho 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm getting this problem while using tabpy. I'm using the sample - supterstore datasets, and I want to cluster the sub-category using the sum([Profit]) and sum([Sales]), but it returns the error:


    ValueError : n_samples=1 should be >= n_clusters=2.
    ​

    Here's my script:

    SCRIPT_str("
    from sklearn.cluster import KMeans
    kmeans = KMeans(n_clusters=2)
    tmp=[]
    for i in range(len(_arg1)):
    tmp.extend([[_arg1,_arg2]])
    KMmodel = kmeans.fit(tmp)
    labels = KMmodel.labels_
    return labels",
    sum([Profit]),sum([Sales]))

    Continue reading...

Compartilhe esta Página