Zip Python Array? -


i have big array:

[['i love these vitamins far', 'and doctor recommended 5000iu  dosage', 'love product!  power vitamin power drink!', 'great  product - works great!', 'love goes vitamin d!', 'great  product', 'best vitamin d3', 'great product! not disappointed.',  'doctor prescribed', 'made in usa'], ['musiclova', 'mg', 'rosie', 'stacey  chillemi "author stacey chillemi"', 'denise', 'jim easley', 'betterlife',  'martin a. leddy', 'angela wright', 'bob jama'],  ['http://www.amazon.com/gp/pdp/profile/a3hjlbnjmsqbq5', etc ..  reviews/r2aq19w7l9d2sp', 'www.amazon.com/gp/customer-reviews/r28ofzc87a7xim',  'www.amazon.com/gp/customer-reviews/r33amkshd88b0q'], 1, 'naturewise'] 

i have 2 elements @ end want applied every array. want create array of arrays inner array being 1 element each list? think using zip easiest way many item unpack?

zip(data)  

for example, want:

   [["i love these vitamins far", "musiclova",     'http://www.amazon.com/gp/pdp/profile/a3hjlbnjmsqbq5', 1, "naturewise"] ..             etc ] 

and of lists have same # of elements, beside last 2 elements not within arrays

if understand correctly, should it:

>>> x = [[1,2,3],['a','b','c'],'me','you'] >>> [list(i)+x[-2:] in zip(*x[:-2])]  >>> [[1, 'a', 'me', 'you'], [2, 'b', 'me', 'you'], [3, 'c', 'me', 'you']] 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -