I have a NumPy dataset with sentence IDs and descriptions values. I would like to create an ordered list in my desired format which is... [['value'], ['value']]
containing just description values. The order of the new list must stay the same as the original so I can match them back to the IDs later.
My issue is that I can't achieve the desired format for the new list instead of [['value'], ['value']]
I get ['value', 'value']
, why?
This is what I have tried:
Original input data:
[
[UUID('11ea1bca-eb95-4dc8-8cb9-c7d70a806679') 'the quick brown fox']
[UUID('339619ab-bd17-401f-82c8-a927145d52cf')' jumps over the lazy dog']
]
Created a new array to store just the description values:
description = np.array([description[1] for description in chunk])
However, this gives me the following output:
['the quick brown fox','jumps over the lazy dog']
My desired output is:
[['the quick brown fox'],[jumps over the lazy dog']]
How can I achieve my desired output keeping the original order?
- Using Python 3.8
- The original list is from
np.array_split(book_information, chunk_size)
which I loop over in chunks
CodePudding user response:
You can simply add the additional dimension when defining your array: description = np.array([[description[1]] for description in chunk])
.