Reputation: 45
I am new to Python (and programming in general!), trying to conduct some data analysis using Pandas.
Using 'Zip' command to zip two lists together, but getting the following error message:
names = ['Bob','Jessica','Mary','John','Mel']
births = [968, 155, 77, 578, 973]
BabyDataSet = zip(names,births)
BabyDataSet
<zip at 0x957ef08>
Running script through Anaconda 2.1.0 (64-bit). Expected output was the x2 lists zipped together to a single list, but instead the appears?
Any help appreciated.
Upvotes: 1
Views: 312
Reputation: 394041
What you are seeing is not an error, the behaviour of zip
changed in python 3 so you need to pass the result of zip to list:
In [2]:
names = ['Bob','Jessica','Mary','John','Mel']
births = [968, 155, 77, 578, 973]
BabyDataSet = list(zip(names,births))
BabyDataSet
Out[2]:
[('Bob', 968), ('Jessica', 155), ('Mary', 77), ('John', 578), ('Mel', 973)]
also seeing as you are going through a tutorial that was written for python 2 then this may be of help: http://www.diveintopython3.net/porting-code-to-python-3-with-2to3.html
Upvotes: 1