我有以下数据帧:
date Values
3/1/2018
3/3/2018 0
3/5/2018 -0.011630952
3/8/2018 0.024635792
3/10/2018
3/10/2018 0.013662755
3/13/2018 2.563770771
3/15/2018 0.026081264
3/17/2018
3/25/2018 4.890818119
3/26/2018
3/28/2018 0.994944572
3/30/2018 0.098569691
4/2/2018
4/2/2018 2.261398315
4/4/2018 2.595984459
4/7/2018 2.145072699
4/9/2018 2.401818037
4/11/2018
4/12/2018 2.233839989
4/14/2018 2.179880142
4/17/2018 0.173141539
4/18/2018
4/19/2018 0.04037559
4/22/2018 2.813424349
4/24/2018 2.764060259
4/27/2018
5/2/2018 4.12789917
5/4/2018 4.282546997
5/4/2018
5/7/2018 5.083333015
5/13/2018
5/14/2018 1.615991831
5/17/2018 0.250209153
5/19/2018 5.003758907
5/20/2018
5/22/2018
5/24/2018 0.177665412
5/29/2018
6/1/2018 3.190019131
6/3/2018 3.514900446
6/5/2018 2.796386003
6/6/2018 4.132686615
6/8/2018
6/11/2018 2.82530117
6/14/2018
6/16/2018 1.786619782
6/18/2018
6/21/2018 1.60535562
6/21/2018 1.737388611
6/23/2018 0.048161745
6/26/2018 1.811254263
6/28/2018 0.109187543
6/30/2018
7/1/2018 0.086753845
7/3/2018 2.141263962
7/6/2018 1.116563678
7/7/2018 1.159829378
7/8/2018 0.107431769
7/11/2018 -0.001963556
7/13/2018
7/16/2018
7/16/2018 0.071490705
7/18/2018 1.052834034
7/21/2018
7/23/2018
7/23/2018 1.201774001
7/28/2018 0.218167484
7/31/2018 0.504413128
8/1/2018
8/2/2018
8/5/2018 1.057194233
8/7/2018 0.85014987
8/8/2018 1.183927178
8/10/2018 1.226516366
8/12/2018 1.533656836
8/15/2018
8/17/2018
8/17/2018 1.355006456
8/20/2018 1.490438223
8/22/2018
8/24/2018 1.160542369
8/25/2018 1.546550632
8/27/2018
8/30/2018
看起来是这样的:
如果两个峰之间的距离小于14天,我想过滤掉峰间的所有波谷。e、 我想过滤掉5/7/2018
和{
根据@Asmus的建议,我希望在最终结果中有一个峰值,因此高斯分布可能是最好的(重点是可能)。在
试试这个:
重要提示:因为这个答案已经很长了,所以我决定完全重写,而不是第五次更新。如果你对“历史背景”感兴趣,去看看版本历史
首先,运行一些必需的导入:
然后清理数据(如上所述,另存为.csv):
^{pr2}$并按每日频率重新编制索引:
现在有趣的是:用一些非对称的线型(Breit-Wigner-Fano)拟合数据,并去除低于某个阈值的“异常值”。我们首先手动声明峰值的位置(我们的初始猜测,我们可以去掉3个点),然后我们再次使用fit(fit 1)作为输入(去掉8个点),最后得到我们的最终拟合。在
根据要求,我们现在可以在之前创建的每日索引上插值拟合(
bwf_result_final.eval(x=idx)
),并在dataframe中创建额外的列:y_fine
,它只保存fit,y_final
,它保存最后的点云(即,在异常值移除之后),以及一个连接的数据集(看起来“参差不齐”)y_joined
。 最后,我们可以根据“精细”的数据范围(df['index']
)来绘制它。在相关问题 更多 >
编程相关推荐