Python 基于矩阵数据集的PyPI包传递熵计算

Python 基于矩阵数据集的PyPI包传递熵计算,python,pandas,matrix,numpy-ndarray,Python,Pandas,Matrix,Numpy Ndarray,我有一个方差-协方差矩阵,我试图用PyIF 0.1包计算转移熵。在Jupyter笔记本中,我尝试了以下代码: import pandas as pd import seaborn import matplotlib.pyplot as plt from PyIF import te_compute as te import numpy as np 此处,1.csv日期为(6x6)矩阵: 。我收到以下错误消息: -----------------------------------------

我有一个方差-协方差矩阵,我试图用PyIF 0.1包计算转移熵。在Jupyter笔记本中,我尝试了以下代码:

import pandas as pd
import seaborn
import matplotlib.pyplot as plt
from PyIF import te_compute as te
import numpy as np
此处,1.csv日期为(6x6)矩阵:

。我收到以下错误消息:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-72-64837a8c877c> in <module>
----> 1 X_1000 = pd.read_csv("1.csv")(6, 1).flatten()
      2 Y_1000 = pd.read_csv("1.csv")(6, 1).flatten()

TypeError: 'DataFrame' object is not callable
我得到以下信息:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-73-92e8b850574f> in <module>
----> 1 TE = te.te_compute(X_1000, Y_1000, k=1, embedding=1, safetyCheck=True, GPU=False)

~/opt/anaconda3/lib/python3.8/site-packages/PyIF/te_compute.py in te_compute(X, Y, k, embedding, safetyCheck, GPU)
     27     assert_true(k>=1, msg="K should be greater than or equal to 1")
     28     assert_true(embedding >= 1, msg='The embedding must be greater than or equal to 1')
---> 29     assert_true(type(X) == np.ndarray, msg='X should be a numpy array')
     30     assert_true(type(Y) == np.ndarray, msg='Y should be a numpy array')
     31     assert_true(len(X) == len(Y), msg='The length of X & Y are not equal')

~/opt/anaconda3/lib/python3.8/unittest/case.py in assertTrue(self, expr, msg)
    763         if not expr:
    764             msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
--> 765             raise self.failureException(msg)
    766 
    767     def _formatMessage(self, msg, standardMsg):

AssertionError: False is not true : X should be a numpy array
---------------------------------------------------------------------------
AssertionError回溯(上次最近的调用)
在里面
---->1 TE=TE.TE_计算(X_1000,Y_1000,k=1,嵌入=1,安全检查=True,GPU=False)
te_compute中的~/opt/anaconda3/lib/python3.8/site-packages/PyIF/te_compute.py(X,Y,k,嵌入,安全检查,GPU)
27 assert_true(k>=1,msg=“k应大于或等于1”)
28 assert_true(嵌入>=1,msg='嵌入必须大于或等于1')
--->29 assert_true(类型(X)==np.ndarray,msg='X应该是一个numpy数组')
30 assert_true(类型(Y)==np.ndarray,msg='Y应该是一个numpy数组')
31 assert_true(len(X)==len(Y),msg='X和Y的长度不相等')
assertTrue(self、expr、msg)中的~/opt/anaconda3/lib/python3.8/unittest/case.py
763如果不是expr:
764 msg=self.\u formatMessage(msg,“%s不是真的”%safe\u repr(expr))
-->765提升自失效异常(msg)
766
767 def_格式消息(self、msg、standardMsg):
AssertionError:False不是true:X应该是numpy数组

克服这一问题的可能行动是什么?提前感谢您的帮助。

代码
X_1000=pd.read\u csv(“1.csv”)
后的括号提高
TypeError
,因为函数
pandas.read\u csv
返回类
pandas.core.frame.DataFrame
的实例,该实例不可调用。这可以通过运行我在这里修改的行来确认,然后打印(键入(X_1000))。非常感谢您的回复。它起作用了。但是X的解决方案应该是一个numpy数组吗?被调用函数的文档对于决定如何进行非常有用:和。IPython中的内省也很有用:。
TE = te.te_compute(X_1000, Y_1000, k=1, embedding=1, safetyCheck=True, GPU=False)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-73-92e8b850574f> in <module>
----> 1 TE = te.te_compute(X_1000, Y_1000, k=1, embedding=1, safetyCheck=True, GPU=False)

~/opt/anaconda3/lib/python3.8/site-packages/PyIF/te_compute.py in te_compute(X, Y, k, embedding, safetyCheck, GPU)
     27     assert_true(k>=1, msg="K should be greater than or equal to 1")
     28     assert_true(embedding >= 1, msg='The embedding must be greater than or equal to 1')
---> 29     assert_true(type(X) == np.ndarray, msg='X should be a numpy array')
     30     assert_true(type(Y) == np.ndarray, msg='Y should be a numpy array')
     31     assert_true(len(X) == len(Y), msg='The length of X & Y are not equal')

~/opt/anaconda3/lib/python3.8/unittest/case.py in assertTrue(self, expr, msg)
    763         if not expr:
    764             msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
--> 765             raise self.failureException(msg)
    766 
    767     def _formatMessage(self, msg, standardMsg):

AssertionError: False is not true : X should be a numpy array