等间隔抽取数据,可以利用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)
array([1.00000000e+00, 2.11919192e+01, 4.13838384e+01, 6.15757576e+01,
8.17676768e+01, 1.01959596e+02, 1.22151515e+02, 1.42343434e+02,
1.62535354e+02, 1.82727273e+02, 2.02919192e+02, 2.23111111e+02,
2.43303030e+02, 2.63494949e+02, 2.83686869e+02, 3.03878788e+02,
3.24070707e+02, 3.44262626e+02, 3.64454545e+02, 3.84646465e+02,
4.04838384e+02, 4.25030303e+02, 4.45222222e+02, 4.65414141e+02,
4.85606061e+02, 5.05797980e+02, 5.25989899e+02, 5.46181818e+02,
5.66373737e+02, 5.86565657e+02, 6.06757576e+02, 6.26949495e+02,
6.47141414e+02, 6.67333333e+02, 6.87525253e+02, 7.07717172e+02,
7.27909091e+02, 7.48101010e+02, 7.68292929e+02, 7.88484848e+02,
8.08676768e+02, 8.28868687e+02, 8.49060606e+02, 8.69252525e+02,
8.89444444e+02, 9.09636364e+02, 9.29828283e+02, 9.50020202e+02,
9.70212121e+02, 9.90404040e+02, 1.01059596e+03, 1.03078788e+03,
1.05097980e+03, 1.07117172e+03, 1.09136364e+03, 1.11155556e+03,
1.13174747e+03, 1.15193939e+03, 1.17213131e+03, 1.19232323e+03,
1.21251515e+03, 1.23270707e+03, 1.25289899e+03, 1.27309091e+03,
1.29328283e+03, 1.31347475e+03, 1.33366667e+03, 1.35385859e+03,
1.37405051e+03, 1.39424242e+03, 1.41443434e+03, 1.43462626e+03,
1.45481818e+03, 1.47501010e+03, 1.49520202e+03, 1.51539394e+03,
1.53558586e+03, 1.55577778e+03, 1.57596970e+03, 1.59616162e+03,
1.61635354e+03, 1.63654545e+03, 1.65673737e+03, 1.67692929e+03,
1.69712121e+03, 1.71731313e+03, 1.73750505e+03, 1.75769697e+03,
1.77788889e+03, 1.79808081e+03, 1.81827273e+03, 1.83846465e+03,
1.85865657e+03, 1.87884848e+03, 1.89904040e+03, 1.91923232e+03,
1.93942424e+03, 1.95961616e+03, 1.97980808e+03, 2.00000000e+03])