python - Pandas :找到高于定义阈值的结束频谱

标签 python pandas dataframe frequency-analysis time-frequency

长期阅读,第一次发帖。

我在 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 = 振幅数据。每种结果的图如下所示:

See x,y Plot of image in this link - not enough points to embed yet

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

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

我如何在 Pandas/python 中检测(由于数据量非常大,最好不进行迭代)以找到最高频率(> -40),这样我就知道频率不会再次返回到 < -40 然后跳转备份? 基本上,我正在尝试找到频带的末端。我已经尝试使用一些 Pandas 统计数据(如果有的话也很好),但未能成功获得有用的数据。

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

这是一个可以用 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

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

关于python - Pandas :找到高于定义阈值的结束频谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60640849/

相关文章:

python - 如何将数据帧的字典写入 Pandas 中的一个 excel 文件?键是工作表名称,值是数据框

python石头剪刀布计数器

python - SQLalchemy 问题从 MSSQL 列恢复二进制数据

python - Firefox 中的 python cgi 问题

python - 如何从python中带有方括号的正则表达式输出中提取内容

python - 如何在 Pandas Python 中更新数据框

python-3.x - 使用重复模式填充 python pandas 数据框中的缺失行

python - Pandas - 从分类列创建 bool 列

python - 未正确调用 DataFrame 构造函数!错误

python - sklearn python中样本数量不一致