Skip to content

Ch. 10 (clustering) bug #317

@darribas

Description

@darribas

Cell 40 (last one of code):

ami_scores = []
# for each cluster solution
for i_cluster_type in ("k5cls", "ward5", "ward5wq", "ward5wknn"):
    # for every other clustering
    for j_cluster_type in ("k5cls", "ward5", "ward5wq", "ward5wknn"):
        # compute the adjusted mutual info between the two
        ami_score = metrics.adjusted_mutual_info_score(
            db[i_cluster_type], db[j_cluster_type]
        )
        # and save the pair of cluster types with the score
        ami_scores.append((i_cluster_type, j_cluster_type, ami_score))
# arrange the results into a dataframe
results = pandas.DataFrame(
    ami_scores, columns=["source", "target", "similarity"]
)
# and spread the dataframe out into a square
results.pivot("source", "target", "similarity")

Currently returns (with pandas 2.1.1) the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[40], line 17
     13 results = pandas.DataFrame(
     14     ami_scores, columns=["source", "target", "similarity"]
     15 )
     16 # and spread the dataframe out into a square
---> 17 results.pivot("source", "target", "similarity")

TypeError: pivot() takes 1 positional argument but 4 were given

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepupChanges to keep up with the evolution of the python stack

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions