我有一个CSV文件('user_id')为100,('Product_id')为16370列。我如何使用Pearson Correlation Coefficient计算用户与用户的相似度。为此,我使用的内置功能python Pearsons,但显示错误。
+-----------------+-------------+-------------+-----------+
| user_id | B004MYH08U | B000BNXDBO | 783229135 |
+-----------------+-------------+-------------+-----------+
| A11L5M4MJP00UW | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A13NO1WIGJZUV4 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A141HP4LYPWMSR | 1 | 4 | 4 |
+-----------------+-------------+-------------+-----------+
| A14HV65O34S8EF | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A174WE983H06N4 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A17RUD7RKGZUA4 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A18758S1PUYIDT | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A19O5ETNRJN39D | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1AFHYBINSG7PH | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1CIW2OEVAJRM2 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1D12NAC1U12F0 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1DDVFGUC6NQD3 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1DZ4MTJY8LAVG | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1FRPGQYQTAOR1 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1I7QGUDP043DG | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1J50B4K22D93F | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1M3W0ROKC7F3C | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1M5405JH9THP9 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1MIFONBFK8OWE | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1MXSUEA3ZK5UZ | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1NN07FHTQZZ6K | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1OUBOGB5970AO | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1R6DF0KOJ0TG6 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1RSDE90N6RSZF | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A1VJCDRXUQVXBM | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A23Q1T4MXZHFM7 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A245OASCPKPJHC | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2582KMXLK2P06 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A27H9DOUGY9FOS | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2942G3FDOIM18 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A295JWKTJLM7YT | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A29DLKCN8QWO7B | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2BTR8ZO8MB01D | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2D595HNMO9PHR | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2DLKD4AC5JV5Q | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2FX6OHBMQ9545 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2H5D7IK9SF07M | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2I6MHMAZZDCRX | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2IMLPUXYQJTSY | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2IOMS4TK2QSFW | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2IT3899H776LW | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2M2O1DI1SCQDI | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2M4H4R4Z7UDZX | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2OKCS5234ZV7S | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2ON9S58W4AZ1Z | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2P7UB02HAVEPB | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2R1VN4J5L2ZCO | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2TTVV34NLMZI8 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2TX99AZKDK0V7 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2UFG3DMVELP6I | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2URPOBDQK3WG | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2VDM3D712BGLE | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2WFI5XFB7NHHJ | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A2YWH9COGWT8VU | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A31YQQYX9PU04Z | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A328S9RN3U5M68 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A34KFDQ5KBHZA5 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A36SSF310LBGSE | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A39I79H1A2A8C3 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A39M64IZTC04G0 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3ENN12GLNTUAF | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3GX0UO7XXZST2 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3IG9WGCIHPJ6X | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3N27L13CWJ9HY | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3N2MVBI1A2I9Y | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3NNR95R50VB4W | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3NPHQVIY59Y0Y | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3NWP0SFAC0ZD2 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3Q4S5DFVPB70D | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3QIEISBZP4QTV | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3QYDL5CDNYN66 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3R95JCH1K9R0S | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3RVH9HUN9J4LZ | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A3VP6XR88INLRB | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A44YJ6ZLTMAR6 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A4FBBS25X3XEL | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A63FDY7VFOMQV | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A66KMXH9V7OGU | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A7LRQFZW3D9NE | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A8DDTUL8OWFMO | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| A9Q28YTLYREO7 | 0 | 3 | 4 |
+-----------------+-------------+-------------+-----------+
| AA72A0AYTWV5Y | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AD4CDZK7D31XP | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AFC8IKR407HSK | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AFJ27ZV9183B8 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AFKMBAY28XO8A | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AH7ZNGM8WOOGN | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AMEJTGF5NQLNH | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| ANZNLFBN62YKH | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AOIT2QUH8GRGA | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AQJVNDW6YZFQS | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| ASES4LU7WKYC | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| ATK3QFC6L1318 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| ATXL536YX71TR | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AUQW6UEZFC7B2 | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AVQRC2N2SSSYS | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AVV8PPI6BDKVA | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AWPODHOB4GFWL | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
| AXMKAXC0TR9AW | 0 | 0 | 0 |
+-----------------+-------------+-------------+-----------+
我已经发布了代码:
from scipy.stats import pearsonr
data = pd.read_csv("result2.csv")
USER = data.iloc[:,0:16370].values
arr =np.array(USER[0]).tostring()
arr2 =np.array(USER[1]).tostring()
vla = pearsonr(arr, arr2)
print(vla)
错误是:TypeError:大小不正确的对象的len()
有人可以帮助我如何使用python查找Pearson相关系数吗? 这里有一个人已经通过这种方式与他联系了?enter link description here