“Series objects are mutable and cannot be hashed” error

后端 未结 2 1413
后悔当初
后悔当初 2020-11-30 02:36

I am trying to get the following script to work. The input file consists of 3 columns: gene association type, gene name, and disease name.

cols = [\'Gene typ         


        
2条回答
  •  借酒劲吻你
    2020-11-30 03:19

    gene_name = no_headers.iloc[1:,[1]]
    

    This creates a DataFrame because you passed a list of columns (single, but still a list). When you later do this:

    gene_name[x]
    

    you now have a Series object with a single value. You can't hash the Series.

    The solution is to create Series from the start.

    gene_type = no_headers.iloc[1:,0]
    gene_name = no_headers.iloc[1:,1]
    disease_name = no_headers.iloc[1:,2]
    

    Also, where you have orph_dict[gene_name[x]] =+ 1, I'm guessing that's a typo and you really mean orph_dict[gene_name[x]] += 1 to increment the counter.

提交回复
热议问题