Note
Numpy (26) 본문
728x90
How to extract a particular column from 1D array of tuples?
# Input:
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
iris_1d = np.genfromtxt(url, delimiter=',', dtype=None)
print(iris_1d.shape)
# output
#> (150,)
# Solution:
species = np.array([row[4] for row in iris_1d])
species[:5]
array([b'Iris-setosa', b'Iris-setosa', b'Iris-setosa', b'Iris-setosa',
b'Iris-setosa'],
dtype='|S18')
'Numpy' 카테고리의 다른 글
Numpy (28) (0) | 2022.08.20 |
---|---|
Numpy (27) (0) | 2022.08.19 |
Numpy (25) (0) | 2022.08.16 |
Numpy (24) (0) | 2022.08.15 |
Numpy (23) (0) | 2022.08.14 |
Comments