• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes

Problem :

I want to get my python script to work. My input file consists of 3 columns: gene_ association_type, gene_name, and disease_name. But I keep facing the bekow error that says:

“Series objects are mutable and cannot be hashed”

Please let me know how can I fix the above error?

by (3k points)  

1 Answer

0 votes

Solution :

I had also faced the similar issue in the recent past. I did lot of research on it and found the solution on it. This is the very common problem with the people getting started. Directly coming to the point the gene_name[x] is the mutable object so you cannot hash it.. To use the object as the key in a dictionary, python needs to use the hash value, and that is the reason behind you facing above error.

More Details :

The Mutable objects are the objects whose value can be changed. For e.g., list is the mutable object, as you can append to it.And int is the immutable object, as you can't change it. When you do:

x = 5;
x = 3;

You are not changing the value of x but you are creating the new object and making x point to the value.

To resolve your error, you must use the immutable objects as the keys in your dictionary. For e.g.: tuplestringint.

by (34.3k points)