So here is the thing. I have a list of lists and some of the list are empty... but if it is not empty.. all the list are of fix length.. the length which I dont know.. For example
for feature in features:
print len(feature)
This will print either 0 or length k.
I am trying to write a function
def generate_matrix(features):
# return matrix
Which returns a numpy matrix.. with empty rows replaces with zero vector. Is there a way to do this efficiently? I mean... I don't want to loop thru to find the shape of matrix and then again loop thru to generate row (with either np.array(feature) or np.zeros(shape)..