Skip to main content

Posts

Showing posts with the label TypeError

TypeError: list indices must be integers or slices, not str

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 th...

Tensorflow Type Error: Type already registered for SparseTensorValue

Tensorflow Type Error: Type already registered for SparseTensorValue "pywrap_tensorflow.RegisterType("SparseTensorValue", SparseTensorValue) TypeError: Type already registered for SparseTensorValue" -- this error pops up in your screen. Your code have been running properly just the last time and now its stuck. Want to figure out why? I have already done that for you. This has something to do with retaining variables due to internal code issues with spyder ide. So you are right, your code is just fine. Just go back and rerun your code once more, but before that, restart the kernel of spyder and it will run smooth.