美文网首页
2019-01-22 numpy

2019-01-22 numpy

作者: 求好运啊 | 来源:发表于2019-01-22 19:10 被阅读0次

numpy 库的学习1

文件导入

import  numpy as np
world_alcohol = numpy.genfromtxt("world_alcohol.txt", delimiter = ",")
print(type(world_alcohol))

genfromtxt()函数:从文本文件加载数据,按指定分隔符分割。
genfromtxt(fname, dtype=<class 'float'>, comments='#', delimiter=None, skip_header=0, skip_footer=0, converters=None, missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars=None, replace_space='_', autostrip=False, case_sensitive=True, defaultfmt='f%i', unpack=None, usemask=False, loose=True, invalid_raise=True, max_rows=None, encoding='bytes')

向量和矩阵

vector = np.array([5, 10, 15, 20])
matrix = np.array([[5, 10, 15],[20, 25, 30], [35, 40, 45]])
print(vector)
print(vector.shape)
print(matrix)
print(matrix.shape)

相关文章

网友评论

      本文标题:2019-01-22 numpy

      本文链接:https://www.haomeiwen.com/subject/lpcrjqtx.html