
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
import numpy
data = numpy.genfromtxt('/Users/apple/PycharmProjects/Carlos_python/data_science/downloadlist.txt',delimiter='',dtype='str') print(type(data))
vector = numpy.array([3,6,7,89,90])
matrix = numpy.array([[12,3,67,9],[34,2,7,9],[3,8,9,6]]) print(vector) print(matrix)
print(vector.shape) print(matrix.shape)
|
<class 'numpy.ndarray'>
[ 3 6 7 89 90]
[[12 3 67 9]
[34 2 7 9]
[ 3 8 9 6]]
(5,)
(3, 4)
1 2 3 4
|
numbers = numpy.array([1,2,3,4,5,6,7,8]) print(numbers) print(numbers.dtype)
|
[1 2 3 4 5 6 7 8]
int64
1 2 3 4
|
matrix = numpy.array([[12,3,67,9],[34,2,7,9],[3,8,9,6]])
print(matrix[0,0])
|
12
1 2 3
|
matrix = numpy.array([[12,3,67,9],[34,2,7,9],[3,8,9,6]])
print(matrix[2,-1])
|
6
1 2 3
|
vector = numpy.array([3,6,7,89,90]) print(vector[0:3])
|
[3 6 7]
1 2 3
|
matrix = numpy.array([[12,3,67,9],[34,2,7,9],[3,8,9,6]])
print(matrix[:,1])
|
[3 2 8]
近期评论