Introduction:
This error generally occur for very simple issues. The error normally translates to python saying that, you are trying to access a string index of a list; which is impossible as lists are indexed by integers and not by strings.
Recreation of the issue:
So this can be caused by something as simple as food = list['abc']. But the problem is that we often write complex codes and therefore we don't easily find out this mistake.
This sort of mistake if you are seeing in your code, please check that most probably you are passing a list in a place where there should be a dataframe or at least a dictionary.
I have several times encountered this error in real coding scenarios. One of them have been where I wrote a condition statement inside a dataframe and this issue came. Later on, I found out that the variable I thought was a dataframe was in fact misspelled and actually was referring to a list I created one line above.
Conclusion:
So, it is important to examine the line where the error is coming and then please check the type of the variables involved in the error. Probably this should solve your issue.
You can check this stackOverFlow link for similar issues.
Thanks for reading this post.
Comments
Post a Comment