[英]How to transform array of strings into matrix with python
what would be the pythonic way to transform multiple arrays of strings into a matrix, where each input string gets its position in the new matrix based on a lexicographical order (or is there even a better criterion?). 将多个字符串数组转换为矩阵的pythonic方法是什么,其中每个输入字符串根据字典顺序(或什至有更好的标准)在新矩阵中获得其位置。
In the end, I would like to be able to query the final matrix strings based on a normalized, common criterion and also be able to find out from which inputarray each particular string originally came from. 最后,我希望能够基于归一化的通用标准来查询最终的矩阵字符串,并且还能够找出每个特定字符串最初来自哪个输入数组。
So for example if I iterate over a bunch of arrays like such (pseudocode!): 因此,例如,如果我遍历一堆这样的数组(伪代码!):
array1 = {'01abc','aabc','cba','xyz','999','zz','ZZ'}
array2 = {'0c','aabc','cc','xz','aZZ'}
array3+n = {'...','...','...','....
I'd like to transform that it into something like this: 我想将其转换为如下形式:
name 0 9 a c x z Z
array1 01abc 999 aabc cba xyz zz ZZ
array2 0c aabc cc xz
array2 aZZ
array3...
I already tried googling 2 hours to find my way, but I just don't have the right terminology to describe my problem properly enough... any ideas that can point me into the right direction will be greatly appreciated. 我已经尝试了2个小时的搜寻,找到了自己的出路,但我只是没有正确的术语来恰当地描述我的问题...任何可以将我引向正确方向的想法将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.