import numpy as np
#2.1.4
#1(1)
names=np.array(['王微','肖良英','方绮雯','刘旭阳','钱易铭'])
subjects=np.array(['Math','English','Python','Chinese','Art','Database','Physics'])
show_sub=subjects[[1,2,4]]
print(show_sub)
show_name=names[-3]
print(show_name)
#1(2)
print(names[2:])
print(subjects[2:5])
#1(3)
mask=(subjects=='English')|(subjects=='Physics')
print(subjects[mask])
#2(1)
scores=np.array([[70,85,77,90,82,84,89],[60,64,80,75,80,92,90],[90,93,88,87,86,90,91],[80,82,91,88,83,86,80],[88,72,78,90,91,73,80]])
print(scores[[0,3]])
print(scores[[1,3]][:,(subjects=='Math')|(subjects=='Python')])
print(scores[:,(subjects=='Math')|(subjects=='Art')])
print(scores[(names=='王微')|(names=='刘旭阳')][:,(subjects=='English')|(subjects=='Art')])
#3
print(np.arange(10,20).reshape(2,5))
[DHU数据科学]2.1.4
于 2024-09-08 10:14:48 首次发布