Your output
variable is not a N x 4
matrix, at least not in python types sense. It is a tuple, which can only be indexed by a single number, and you try to index by tuple (2 numbers with coma in between), which works only for numpy matrices. Print your output, figure out if the problem is just a type (then just convert to np.array) or if you are passing something completely different (then fix whatever is producing output
).
Example of what is happening:
import numpy as np output = ((1,2,3,5), (1,2,1,1)) print output[1, 2] # your error print output[(1, 2)] # your error as well - these are equivalent calls print output[1][2] # ok print np.array(output)[1, 2] # ok print np.array(output)[(1, 2)] # ok print np.array(output)[1][2] # ok
Related Posts:
- Python Pandas: Get index of rows which column matches certain value
- Python Pandas: Get index of rows which column matches certain value
- Append a tuple to a list – what’s the difference between two ways?
- How to reset index in a pandas dataframe? [duplicate]
- IndexError: too many indices for array
- IndexError: too many indices for array
- Finding the index of an item in a list
- What is an index in SQL?
- Finding the index of an item in a list
- TypeError: ‘float’ object is not subscriptable
- Double precision floating values in Python?
- TypeError: ‘float’ object is not subscriptable
- Convenient way to deal with ValueError: cannot reindex from a duplicate axis
- What are “named tuples” in Python?
- Double precision floating values in Python?
- What’s the canonical way to check for type in Python?
- IndexError: too many indices for array
- django: TypeError: ‘tuple’ object is not callable
- TypeError: ‘float’ object is not callable
- Python convert tuple to string
- Error”Can only compare identically-labeled Series objects” and sort_index
- Convert list to tuple in Python
- Index Error: list index out of range (Python) [duplicate]
- TypeError: ‘str’ object cannot be interpreted as an integer [duplicate]
- What is dtype(‘O’), in pandas?
- What is dtype(‘O’), in pandas?
- How to determine a Python variable’s type?
- Change column type in pandas
- Python: find position of element in array
- Determine the type of an object?
- How to remove an element from a list by index
- Python add item to the tuple
- Python: tuple indices must be integers, not str when selecting from mysql table
- How to index into a dictionary?
- Pop index out of range
- Get first row value of a given column
- How to check if type of a variable is string?
- What does ‘index 0 is out of bounds for axis 0 with size 0’ mean?
- What does ‘index 0 is out of bounds for axis 0 with size 0’ mean?
- How to sort a list/tuple of lists/tuples by the element at a given index?
- Add Variables to Tuple
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Why is there no tuple comprehension in Python?
- Why is there no tuple comprehension in Python?
- Pandas split DataFrame by column value
- Python AttributeError: ‘dict’ object has no attribute ‘append’
- How does tuple comparison work in Python?
- What datatype should be used for storing phone numbers in SQL Server 2005?
- How to convert index of a pandas dataframe into a column
- TypeError: can only concatenate tuple (not “str”) to tuple Error
- creating sets of tuples in python
- How to print a specific row of a pandas DataFrame?
- TypeError: can only concatenate tuple (not “int”) in Python
- Conditional indexing with Numpy ndarray
- Can I put a tuple into an array in python?
- Python convert tuple to string
- Does Python have an immutable list?
- Converting string into datetime
- What does the list() function do in Python?
- raw_input function in Python
- How to execute a program or call a system command?
- Adding new column to existing DataFrame in Python pandas
- How do I get the row count of a Pandas DataFrame?
- Singular matrix issue with Numpy
- TypeError: ‘dict’ object is not callable
- Error in Python script “Expected 2D array, got 1D array instead:”?
- Get list from pandas dataframe column or row?
- How do you express binary literals in Python?
- main loop ‘builtin_function_or_method’ object is not iterable
- How to prompt for user input and read command-line arguments
- What is Python buffer type for?
- Empty set literal?
- How can I check file size in Python?
- Any way to clear python’s IDLE window?
- Shuffle DataFrame rows
- What is the point of float(‘inf’) in Python?
- How to reinstall a pip package even if it exists
- Catch multiple exceptions in one line (except block)
- How to get the current working directory using python 3?
- Two dimensional array in python
- printing a two dimensional array in python
- ImportError: no module named win32api
- Remove quotes from String in Python
- How to change plot background color?
- ImportError: No module named ‘bottle’ – PyCharm
- What does “& 0x7fffffff” mean in “int(time.time()*1000.0) & 0x7FFFFFFF”
- How to compare individual characters in two strings in Python 3
- Unsupported operand type(s) for +: ‘float’ and ‘str’ error
- Plotting multiple lines, in different colors, with pandas dataframe
- if var == False
- Python for C++ Developers
- Could not install packages due to an EnvironmentError: [Errno 13]
- Generator expression must be parenthesized if not sole argument
- Get a Try statement to loop around until correct value obtained
- Does python have header files like C/C++?
- Making a POST call instead of GET using urllib2
- Extract first and last row of a dataframe in pandas
- bound method Response.json of Response [200]
- Convert int to ASCII and back in Python
- Declaration is incompatible with type