McLeodx - 4 months ago 17

Python Question

I have a numpy array with arrays within it:

`array([[1,2,3],[4,5,6],[7,8,9]])`

How am I able to find the maximum of all of the last elements of these inner arrays? ie. for this case the return would be 9

`(max(3,6,9))`

I'm able to do this by converting to a Pandas dataframe first, but this is slowing down the program and I'm sure there's an easier way just using np.

Answer

Assuming that you meant to write

```
array([[1,2,3],[4,5,6],[7,8,9]])
```

then you can slice the last column with `A[:,-1]`

and call `.max()`

.