1. # coding=utf-8
    2. import numpy as np
    3. us_file_path = "./youtube_video_data/US_video_data_numbers.csv"
    4. uk_file_path = "./youtube_video_data/GB_video_data_numbers.csv"
    5. # t1 = np.loadtxt(us_file_path,delimiter=",",dtype="int",unpack=True)
    6. t2 = np.loadtxt(us_file_path,delimiter=",",dtype="int")
    7. # print(t1)
    8. print(t2)
    9. print("*"*100)
    10. #取行
    11. # print(t2[2])
    12. #取连续的多行
    13. # print(t2[2:])
    14. #取不连续的多行
    15. # print(t2[[2,8,10]])
    16. # print(t2[1,:])
    17. # print(t2[2:,:])
    18. # print(t2[[2,10,3],:])
    19. #取列
    20. # print(t2[:,0])
    21. #取连续的多列
    22. # print(t2[:,2:])
    23. #取不连续的多列
    24. # print(t2[:,[0,2]])
    25. #去行和列,取第3行,第四列的值
    26. # a = t2[2,3]
    27. # print(a)
    28. # print(type(a))
    29. #取多行和多列,取第3行到第五行,第2列到第4列的结果
    30. #去的是行和列交叉点的位置
    31. b = t2[2:5,1:4]
    32. # print(b)
    33. #取多个不相邻的点
    34. #选出来的结果是(0,0) (2,1) (2,3)
    35. c = t2[[0,2,2],[0,1,3]]
    36. print(c)