等间隔抽取数据,可以利用numpy里面的linspace,代码如下:
import numpy as np
# 1表示开始位置
# 2000表示结束位置
# 100表示抽取数据个数
# int表示转换为整型数据,默认是float
np.linspace(1, 2000, 100, dtype=int)
# 输出
array([ 1, 21, 41, 61, 81, 101, 122, 142, 162, 182, 202,
223, 243, 263, 283, 303, 324, 344, 364, 384, 404, 425,
445, 465, 485, 505, 525, 546, 566, 586, 606, 626, 647,
667, 687, 707, 727, 748, 768, 788, 808, 828, 849, 869,
889, 909, 929, 950, 970, 990, 1010, 1030, 1050, 1071, 1091,
1111, 1131, 1151, 1172, 1192, 1212, 1232, 1252, 1273, 1293, 1313,
1333, 1353, 1374, 1394, 1414, 1434, 1454, 1475, 1495, 1515, 1535,
1555, 1575, 1596, 1616, 1636, 1656, 1676, 1697, 1717, 1737, 1757,
1777, 1798, 1818, 1838, 1858, 1878, 1899, 1919, 1939, 1959, 1979,
2000])
默认的float输出情况
np.linspace(1, 2000, 100)
arra