Note

Numpy (25) 본문

Numpy

Numpy (25)

알 수 없는 사용자 2022. 8. 16. 20:01
728x90

How to import a dataset with numbers and texts keeping the text intact in python numpy?

# Solution
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
iris = np.genfromtxt(url, delimiter=',', dtype='object')
names = ('sepallength', 'sepalwidth', 'petallength', 'petalwidth', 'species')

# Print the first 3 rows
iris[:3]

# output
array([[b'5.1', b'3.5', b'1.4', b'0.2', b'Iris-setosa'],
	   [b'4.9', b'3.0', b'1.4', b'0.2', b'Iris-setosa'],
       [b'4.7', b'3.2', b'1.3', b'0.2', b'Iris-setosa']], dtype=object)

'Numpy' 카테고리의 다른 글

Numpy (27)  (0) 2022.08.19
Numpy (26)  (0) 2022.08.17
Numpy (24)  (0) 2022.08.15
Numpy (23)  (0) 2022.08.14
Numpy (22)  (0) 2022.08.13
Comments