【发布时间】:2021-11-04 23:21:26
【问题描述】:
我有一个这样的矩阵:
RCA = pd.DataFrame(
data=[
(1,0,0,0),
(1,1,1,0),
(0,0,1,0),
(0,1,0,1),
(1,0,1,0)],
columns=['ct1','ct2','ct3','ct4'],
index=['ind_1','ind_2','ind_3','ind_4','ind_5'])
我正在计算:
norms = RCA.sum()
norm = np.maximum.outer(norms, norms)
我收到了这个错误:
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-9-4fd04a55ad8c> in <module>
4
5 norms = RCA.sum()
----> 6 norm = np.maximum.outer(norms, norms)
7 proximity = RCA.T.dot(RCA).div(norm)
8
~/opt/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/core/series.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs)
746 return None
747 else:
--> 748 return construct_return(result)
749
750 def __array__(self, dtype=None) -> np.ndarray:
~/opt/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/core/series.py in construct_return(result)
735 if method == "outer":
736 # GH#27198
--> 737 raise NotImplementedError
738 return result
739 return self._constructor(result, index=index, name=name, copy=False)
NotImplementedError:
这在 Python 2.7 中完美运行,但我需要在 Python 3.x 中运行它
我需要找到解决此问题的方法。非常感谢。
【问题讨论】:
标签: python python-3.x numpy matrix