Numpy array

Sharan Basappa sharan.basappa at gmail.com
Sat May 19 00:50:12 EDT 2018


This is regarding numpy array. I am a bit confused how parts of the array are being accessed in the example below.

1 import scipy as sp
2 data = sp.genfromtxt("web_traffic.tsv", delimiter="\t")
3 print(data[:10])
4 x = data[:,0]
5 y = data[:,1]

Apparently, line 3 prints the first 10 entries in the array
line 4 & 5 is to extract all rows but only 1st and second columns alone for x and y respectively.

I am confused as to how data[:10] gives the first 10 rows while data[:,0] gives all rows




More information about the Python-list mailing list