TypeError: Passing a dict as an indexer is not supported. Use a list instead.
Jump to turn (11)
- 1TypeError: Passing a dict as an indexer is not supported. Use a list instead.
- 2用中文回答
- 3检查代码有没有问题actions = ['C', 'D'] def chooseaction(s): if random.uniform(0,1)<epsilo
- 4ValueError: columns cannot be a set
- 5用中文回答
- 6检查代码actions = {'C', 'D'} states = [0,1] Qtable = pd.DataFrame(data=[[0 for in ac
- 7刚刚代码报错ValueError: columns cannot be a set
- 8程序actions = {'C', 'D'} states = [0,1] Qtable = pd.DataFrame(data=[[0 for in acti
- 9KeyError: 0 报错怎么解决
- 10程序actions = ['C', 'D'] states = [0,1] Qtable = pd.DataFrame(data=[[0 for in acti
- 11依旧报错
- User
TypeError: Passing a dict as an indexer is not supported. Use a list instead.
- Assistant
This error occurs when you try to use a dictionary as an indexer (or subscript) on an object that only supports list indexing.
For example, let's say you have a list called
my_listand you want to access an element using a dictionary as an index:codemy_list = [1, 2, 3] index = {'key': 0} element = my_list[index]In this case, the dictionary
indexis being passed as an indexer to the listmy_list, which is not supported. To fix this error, you should use a list instead of a dictionary as an index:codemy_list = [1, 2, 3] index = [0] element = my_list[index]Now, the value
0is wrapped in a list and can be used as an index to access the element at index0in .