I’ve used the zip function from the Numpy library to sort tuples and now I have a list containing all the tuples. I had since modified that list and now I would like to restore the tuples so I can use my data. How can I do this?
I’ve used the zip function from the Numpy library to sort tuples and now
Share
should give you the unzipped list.
*zipped_listunpacks the zipped_list object. it then passes all the tuples from the zipped_list object to zip, which just packs them back up as they were when you passed them in.so if:
then
zipped_list = zip(a,b)gives you:and
*zipped_listgives you backzipping that with
zip(*zipped_list)gives you back the two collections: