Pandas:找到高于定义阈值的末端频谱



长期读者,首次发布。

我正在Pandas DataFrames中使用x,y数据绘制频率响应图。以下是数据和绘图的示例(请参阅文章末尾的完整.csv文件(:

fbc['x'],fbc['y']
(0    [89.25, 89.543, 89.719, 90.217, 90.422, 90.686...
1    [89.25, 89.602, 90.422, 90.568, 90.744, 91.242...
2    [89.25, 89.689, 89.895, 90.305, 91.008, 91.74,...
3    [89.25, 89.514, 90.041, 90.275, 90.422, 90.832...
Name: x, dtype: object,
0    [-77.775, -77.869, -77.766, -76.572, -76.327, ...
1    [-70.036, -70.223, -71.19, -71.229, -70.918, -...
2    [-73.079, -73.354, -73.317, -72.753, -72.061, ...
3    [-70.854, -71.377, -74.069, -74.712, -74.647, ...
Name: y, dtype: object)

其中x=频率,y=幅度数据。每一个的结果图如下所示:

请参阅此链接中的x,y图像图-没有足够的点来嵌入

我可以为Dataframe中的x,y数据的每一行创建一个绘图。

在Pandas(Python(中,我需要做的是在频率响应(永久(降至本底噪声之前识别数据中的最高频率。正如您所看到的,在某些地方,y数据可能会达到非常低的值(比如<-50(,但随后会返回到>-40。

我如何在Pandas/python中进行检测(由于数据大小非常大,理想情况下无需迭代(以找到最高频率(>-40(,从而知道频率不会返回&lt-40岁,然后再跳起来基本上,我正在努力寻找频带的尽头。我尝试过使用一些大熊猫的统计数据(如果有也很好(,但未能获得有用的数据。

提前感谢您提供的任何指导和方向。

以下是一个可以使用csv.reader导入的.csv文件:https://www.dropbox.com/s/ia7icov5fwh3h6j/sample_data.csv?dl=0

我相信我已经想出了一个解决方案:

根据@katardin的建议,我提出了以下建议,尽管我认为它可以优化。同样,我将处理大量的数据,所以如果有人能找到一个更优雅的解决方案,我将不胜感激。

for row in fbc['y']:
list_reverse = row
# Reverse y data so we read from end (right to left)
test_list = list_reverse[::-1]
# Find value of y data above noise floor (>-50)
res = next(x for x, val in enumerate(test_list) if val > -50) 
# Since we reversed the y data we must take the opposite of the returned res to 
# get the correct index
index = len(test_list) - res
# Print results
print ("The index of element is : " + str(index))

其中输出为索引编号,如下所示:

The index of element is : 2460
The index of element is : 2400
The index of element is : 2398
The index of element is : 2382

我检查过的每一个都对应于我一直在寻找的确切的高频滚降点。很好的建议!

最新更新