Python Forum
2 Dimensional NumPy for beginners
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 Dimensional NumPy for beginners
#1
Hi there, I don't understand the answer to this task:

This is the task:

import numpy as np

# Subway ridership for 5 stations on 10 different days
ridership = np.array([
[ 0, 0, 2, 5, 0],
[1478, 3877, 3674, 2328, 2539],
[1613, 4088, 3991, 6461, 2691],
[1560, 3392, 3826, 4787, 2613],
[1608, 4802, 3932, 4477, 2705],
[1576, 3933, 3909, 4979, 2685],
[ 95, 229, 255, 496, 201],
[ 2, 0, 1, 27, 0],
[1438, 3785, 3589, 4174, 2215],
[1342, 4043, 4009, 4665, 3033]

if True:
print ridership[1:3, 3:5]

Answer:
[[2328 2539]
[6461 2691]]

But why?
If we have [1:3] that means Row: 1 column 3 --> The answer should be: 2328 and not [2328 2539]
If we have [3:5] that means Row: 3 column 5 --> No answer....

Can somebody explain me, the new python user Angel , why the answer is correct? Or maybe send me a link to the video tutorial/blog what ever.....

Thank you!
J
Reply


Messages In This Thread
2 Dimensional NumPy for beginners - by Jack_Sparrow - May-08-2018, 05:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 688 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,669 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  PyTorch for beginners OmegaRed94 1 1,115 Jun-09-2022, 09:20 PM
Last Post: Larz60+
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 3,026 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  How to add an element such as an average to a multi-dimensional array? xhughesey 6 4,045 Jan-06-2019, 10:47 PM
Last Post: xhughesey
  Three-dimensional Contour Plots minifizikus 1 3,296 Sep-13-2018, 10:56 PM
Last Post: Larz60+
  Recurse through n-dimensional array ColdDeath 2 2,999 Apr-05-2018, 11:20 AM
Last Post: KenniT
  Two Dimensional Chart from CSV File srini1995 0 2,249 Nov-27-2017, 07:10 AM
Last Post: srini1995
  How to sum elements of same position in n dimensional array Felipe 2 4,154 May-11-2017, 10:33 AM
Last Post: Felipe

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020