obsFirstClassArray = [479, 1448.147, 541.692, 1184.73, 2668.818, 1159.531, 525.242, 715.489, 711.0, 422.358, 1681.012, 2418.123, 1798.0, 1756.264, 2015.973, 1318.292, 2106.042, 528.5, 415.244, 3796.11, 1047.01, 1516.165, 646.705, 1637.236, 2337.71, 1059.644, 3215.303, 2756.235, 3192.125, 3274.501, 1204.304, 1737.25, 907.489, 1824.506, 628.075, 453.591, 964.125, 710.029, 717.817, 1393.557, 1426.171, 416.072, 739.597, 419.729, 1477.92, 1046.108, 1152.492, 3415.375, 3154.497, 3641.262, 3722.41, 3611.676, 3762.858, 689.71, 3649.2, 2052.045, 1127.46, 957.21, 570.256, 673.569, 2595.0, 3622.948, 3672.778, 747.099, 2459.65, 517.867, 540.28, 514.078, 2737.375, 3221.398, 2872.977, 754.37, 1106.124, 997.063, 1224.915, 466.911, 2729.25, 3109.625, 2067.125, 1130.5, 1621.376, 1957.471, 3808.968, 2326.75, 1421.764, 7009.088, 5930.857, 9186.095, 13291.356, 23698.799, 8798.074, 21714.114, 15574.125, 11112.625, 14937.0, 4351.402, 11384.579, 10564.059, 7223.75, 27821.241, 6405.0, 5030.387, 11452.005, 4915.75, 20737.125, 16062.25, 29792.424, 7617.884, 33135.874, 15092.375, 22489.929, 22787.852, 10443.0, 20199.447, 29725.186]
def withinBoundary(p,bound):
if (bound[0] <= p < bound[1]):
return p
else:
return None
minBoundary = [403.341,33882.0162,131936.8323]
maxBoundary = [33882.0162,131936.8323,980586.2055]
bound=zip(minBoundary,maxBoundary)
for i in obsFirstClassArray:
for j in bound:
if (withinBoundary(i,j)!=None):
print i, " is between", j[0]," and ",j[1]
I want to get individual set of data between the specified range e.g [403.341- 33882.0162] in a list? How can I achieve this? So, far I am getting output something like following
8777.9956 is between 403.341 and 33882.0162
5877.80875 is between 403.341 and 33882.0162
5673.10075 is between 403.341 and 33882.0162
76450.3483 is between 33882.0162 and 131936.8323
-在上述示例中,输出这些数字
(8777.9956,5877.80875,5673.10075) lies between 403.341 and 33882.0162 and (76450.3483) lies between 33882.0162 and 131936.8323.
如何将输出转换为单个数字列表?我的输出应该是
list403.341 _33882.0162 = [8777.9956,5877.80875,5673.10075]
list33882.0162_131936.8323 = [76450.3483]
是否可以将list403.341\u 33882.0162=[8777.99565877.808755673.10075]存储到变量中? 我们将非常感谢你的帮助。谢谢。你知道吗
产生:
请注意,您的数据不包含您在输出中预期的值。那是个下流的把戏。你知道吗
使用python的filter:
您也可以使用列表理解:
为了存储结果,建议不要将结果绑定到变量,而是使用列表。你知道吗
这是你的输出
相关问题 更多 >
编程相关推荐