【发布时间】:2021-10-05 00:07:39
【问题描述】:
我有对象列表,我想在 python 中将其转换为稀疏矩阵。
我希望矩阵列是标签,行是标题 (不同标题之间可能有重复标签)
我不知道该怎么办?
data = [
{
'title': 'title1', 'tags': ['tag1', 'tag2', 'tag3']
},
{
'title': 'title2', 'tags': ['tag1']
}
]
【问题讨论】:
-
有多少个标签?你事先知道吗?你在用熊猫吗?如果不是,为什么不呢? numpy 呢?
标签: python python-3.x list matrix sna