基于条件的单个数据帧列的度量之间的相关性

问题描述

我正在尝试在一个数据帧列中计算两种测量类型之间的相关性。

所以我想要高度和距离之间的两个相关数字:

  1. 忽略R / THETA / SCALE值
  2. 给定R / THETA / SCALE值的相关性

数据框如下所示:

注意:由于输入无效,给定R / THETA / SCALE的某些行可能为NaN

R THETA SCALE   TYPE     VALUE

1  1     1     Height     20.2
1  1     1     distance   25.3
1  2     1     Height     26
1  2     1     distance   22.2
1  2     1     Height     nan
1  2     1     distance   23.2    

dfs = []
measures_to_correlate = ['Height','distance']
for measure in measures_to_correlate:
    new_df = self.aggregated_data[self.aggregated_data['TYPE'] == measure]
    df = new_df.dropna()
    dfs.append(df)
dfs[0]['VALUE'].corr(dfs[1]['VALUE'])

这是我尝试获得#1的尝试,但返回NaN

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)