• Register
0 votes
6.5k views

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?

7 5 2
3,870 points

Please log in or register to answer this question.

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.

9 7 4
38,600 points
Or you could add a __hash__() method to the object in question, as long as you're happy the hash created by it won't be modified within your code - potentially dangerous but has its uses

Related questions

0 votes
1 answer 54 views
54 views
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?
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 6 views
6 views
Problem: The input file consists of 3 columns: gene association type, gene name, and disease name. I keep getting an error that says: Series objects are mutable and cannot be hashed Any help would be dearly appreciated!
asked Mar 24 ummesalma 29.2k points
0 votes
1 answer 4 views
4 views
Problem: I want to use the dataframes (labels and varieties) for crosstab function. Please do let me know how I can do that?
asked 4 days ago salim1 60.6k points
0 votes
1 answer 54 views
54 views
Problem: I don’t know why I’m getting this typeerror: 'dataframe' objects are mutable, thus they cannot be hashed. Kindly Help…!
asked Mar 6 Umar Ahmad 4.1k points
0 votes
1 answer 103 views
103 views
Problem: dataframe' objects are mutable, thus they cannot be hashed.
asked Feb 16 charles mathews 5.5k points
0 votes
1 answer 37 views
37 views
Problem: I am having this problem 'dataframe' objects are mutable, thus they cannot be hashed. Can anyone help..!
asked Mar 5 Umar Ahmad 4.1k points
0 votes
2 answers 67 views
0 votes
1 answer 462 views
0 votes
1 answer 38 views
0 votes
2 answers 36 views
36 views
Problem: I am little bit confused about this error, i have no idea how can i will solve it, if anyone of you know the solution of this error then answer me please.
asked Apr 4 niyatiry 3.9k points