簡體   English   中英

調用 func pearsonr 和 Got TypeError: 沒有找到匹配指定簽名和轉換的循環用於 ufunc add

[英]Call func pearsonr and Got TypeError: No loop matching the specified signature and casting was found for ufunc add

我運行下面的代碼並收到意外錯誤“TypeError:沒有找到匹配指定簽名的循環,並且為 ufunc add 找到了強制轉換”,其中 X 和 Y 都是數據幀

from scipy.stats import pearsonr
for i in range(X.shape[1]):
    Pear_corr, _ = pearsonr(Y,pd.DataFrame(X.iloc[:,i]))

我該怎么辦 ? 先感謝您

就我而言,拋出錯誤是因為我有 Y 和 X 形狀的二維 numpy 數組 (1000,1)。我將它們展平(y_val.flatten()、y_predict.flatten())並且錯誤得到修復。

TypeError: ufunc 'add' 不包含簽名匹配類型 dtype(' <u1') dtype('<u1') dtype('<u1')< div><div id="text_translate"><p> 我是 Python 用戶的初學者。 當我嘗試在下面編寫代碼時發生錯誤</p><pre>import numpy as np np.array(['a', 'b', 'c']) + np.array(['d','e', 'f'])</pre><pre> TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('&lt;U1') dtype('&lt;U1') dtype('&lt;U1')</pre><p> 所以我嘗試設置dtype = '&lt;U1' ,但它沒有用</p><pre>import numpy as np np.array(['a', 'b', 'c'], dtype='&lt;U1') + np.array(['d','e', 'f'], dtype='&lt;U1')</pre><p> 如何無錯誤地連接那些 np.arrays ?</p></div></u1')>

[英]TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U1') dtype('<U1') dtype('<U1')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 Pearsonr:TypeError:沒有找到與指定簽名匹配的循環,並且為 ufunc add 找到了轉換 TypeError:沒有找到與指定簽名匹配的循環,並且為 ufunc greater 找到了轉換 Seaborn TypeError: No loop match the specified signature and cast was found for ufunc add when using hue np.linalg.lstsq(X,Y)[0] - TypeError: No loop match the specified signature and cast was found for ufunc lstsq_n 類型錯誤:ufunc &#39;add&#39; 不包含具有簽名匹配類型的循環 獲取沒有匹配指定簽名和轉換錯誤的循環 ufunc &#39;add&#39; 不包含簽名匹配類型 dtype 的循環 TypeError:ufunc&#39;add&#39;不包含帶有ARIMA模型簽名的循環 TypeError: ufunc 'add' 不包含簽名匹配類型 dtype(' <u1') dtype('<u1') dtype('<u1')< div><div id="text_translate"><p> 我是 Python 用戶的初學者。 當我嘗試在下面編寫代碼時發生錯誤</p><pre>import numpy as np np.array(['a', 'b', 'c']) + np.array(['d','e', 'f'])</pre><pre> TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('&lt;U1') dtype('&lt;U1') dtype('&lt;U1')</pre><p> 所以我嘗試設置dtype = '&lt;U1' ,但它沒有用</p><pre>import numpy as np np.array(['a', 'b', 'c'], dtype='&lt;U1') + np.array(['d','e', 'f'], dtype='&lt;U1')</pre><p> 如何無錯誤地連接那些 np.arrays ?</p></div></u1')> Numpy polyfit ufunc中的Python TypeError不包含具有匹配簽名類型的循環
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM