python - How to get Adjacency Matrix or pairs from two columns(key, value)?
问题描述
I got a dataframe with two columns(key, value)
key,value
1,A
1,B
2,B
2,C
how to get an adjacency matrix or adjacency pairs(connect values if they have the same key), something like
A B C
A 0,1,0
B 1,0,1
C 0,1,0
I tried pandas.crosstab, which works fine on small data, but got memory error on a big dataframe(3,000,000 rows, 500,000 distinct value). Any help would be appreciated.
解决方案
推荐阅读
- java - 使用 java 8 流重构循环
- c# - EF Core并发,实体框架中SQL加法(+=)的等价物是什么?
- android - 在活动页面上显示生物特征身份验证对话框,而不是将其显示为警报对话框
- angular - 使用多个 NG Bootstrap 日期选择器时令人困惑的按钮焦点
- wordpress - cPanel 电子邮件与邮件递送服务 (Mailgun) 与电子邮件服务器托管
- ssl - 使用自签名证书 cURL 本地 GO 服务器
- c# - SkiaSharp 中风是否有“插入”对齐?
- javascript - 如何修复 jquery 3.4 中已弃用的 :eq 选择器
- java - 按 ID 查找无法在 Spring Boot 中工作
- sql - SQL 效率