Travel Tips
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
numpy练习
import numpy as np import pandas as pd
a1 = np.array([1,2,'a','hello',[1,2,3],{'one':100,'two':200}]) a2 = np.array([list(range(6)), list('abcdef'), [True, False, True, False, True, True]]) print(a1,'\na1的shape为:',a1.shape, '\n-------') print(a2,'\na2的shape为:',a2.shape, '\n-------')
print(np.arange(5,15)) # 作业3:按照要求创建以下数组 print(np.zeros((4,4)), '\n-------') print(np.ones((2,3)), '\n-------') print(np.eye(3, dtype='int'), '\n-------')
Numpy通用函数 课程作业
ar = np.arange(20) print(ar.reshape(4,5), '\n-------') print(np.resize(ar,(5,6)), '\n-------')
ar = np.arange(16).reshape(4,4) print(ar.astype(np.str))
ar = np.arange(16).reshape(4,4) print('创建数组为:\n', ar, '\n-------') result = ar * 10 +100 print('计算后的数组为:\n', result, '\n-------') print('result的均值为:\n', result.mean(), '\n-------') print('result求和为:\n', result.sum(), '\n-------')
ar = np.arange(25).reshape(5,5) print(ar, '\n-------') print('ar[4]是:\n',ar[4], '\n-------') print('ar[:2,3:]是:\n',ar[:2,3:], '\n-------') print('ar[3][2]是:\n',ar[3][2], '\n-------')
ar = np.arange(10).reshape(2,5) print(ar, '\n-------') print('大于5的值为:',ar[[ar>5]])
ar = np.arange(25, dtype = np.float32).reshape(5,5) print(ar, '\n-------') ar[:2,:2] = np.random.rand(2,2) print('结果为:\n',ar, '\n-------')
ar1 = np.random.normal(size = (2,5)) ar2 = np.random.normal(size = (2,5)) print(ar1, '\n-------') print(ar2, '\n-------') print('结果为:\n',np.vstack((ar1,ar2)))
import os os.chdir('/home/zty/Documents/python/Python进阶数据分析及可视化/数据解析核心/CH01科学计算工具:Numpy') ar = np.random.randint(100,size=(10,10)) print(ar,'\n--------') np.savetxt('array.txt',ar, delimiter=',',fmt = '%i') print('finished!')
Sed ac lorem felis. Ut in odio lorem. Quisque magna dui, maximus ut commodo sed, vestibulum ac nibh. Aenean a tortor in sem tempus auctor
December 4, 2020 at 3:12 pm
Sed ac lorem felis. Ut in odio lorem. Quisque magna dui, maximus ut commodo sed, vestibulum ac nibh. Aenean a tortor in sem tempus auctor
December 4, 2020 at 3:12 pm
Donec in ullamcorper quam. Aenean vel nibh eu magna gravida fermentum. Praesent eget nisi pulvinar, sollicitudin eros vitae, tristique odio.
December 4, 2020 at 3:12 pm
我是 s enim interduante quis metus. Duis porta ornare nulla ut bibendum
Rosie
6 minutes ago