Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
BUG: in Python3 MultiIndex.from_tuples cannot take "zipped" tuples #18434
Code Sample, a copy-pastable example if possible
# This code fails in python 3 import pandas as pd my_index = pd.MultiIndex.from_tuples(zip(['a', 'b'], ['c', 'd'], ['e', 'f']), names=['A','B', 'C'])
The code above gives an Exception
TypeError: object of type 'zip' has no len()
Because in python3, unlike in python2, the return from zip is NOT a list and cannot get length.
In pandas, there are multiple instances in MultiIndex and related classes, where the code tries to get len() from the arguments, which are valid input but no longer have len property in python3.
Same as in python2
MultiIndex(levels=[['a', 'b'], ['c', 'd'], ['e', 'f']], labels=[[0, 1], [0, 1], [0, 1]], names=['A', 'B', 'C'])
we generally support list-likes / iterables for most operations (for certain types of indexing a tuple is distinstince). so for the
@Xbar would you do a PR for this?