【发布时间】:2014-07-05 16:47:52
【问题描述】:
如何使用 python 删除二维数组中的空格..我已经编写了如下代码.. 代码:
MI_feature_matrix_POS = [["" for x in xrange(2)] for x in xrange(1000)]
##### perform some opeation and assign some values into the matrix..and sort the matrix
sorted_MI_feature_rank_list = sorted ( MI_feature_matrix, key=lambda MI_feature_matrix: MI_feature_matrix[0], reverse = False )
sorted_MI_feature_rank_list_POS=filter(None, sorted_MI_feature_rank_list_POS)
numrows = len(sorted_MI_feature_rank_list_POS)
for i in range(0,numrows):
print sorted_MI_feature_rank_list_POS[i]
> output:
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> []
> ['addicted', '0.00010118008040085441']
> ['admitted', '0.00010118008040085441']
> ['age', '0.00010118008040085441']
> ['anecdote', '0.00010118008040085441']
> ['arguement', '0.00010118008040085441']
> ['banana', '0.00010118008040085441']
....
我想从这个矩阵中删除这个空格?可以吗??
【问题讨论】:
-
你在哪里使用
MI_feature_matrix_POS? -
这是我排序前的原始矩阵..
标签: python matrix multidimensional-array