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
Index created from empty generator raises TypeError #21470
Code Sample, a copy-pastable example if possible
# returns Index(, dtype='object') pd.Index() # returns Index(['a', 'b', 'c'], dtype='object') pd.Index(x for x in ['a', 'b', 'c']) # raises TypeError: Cannot infer number of levels from empty list pd.Index(x for x in )
The Index constructor accepts most generators/iterables without issue as if they were a realized list. However, if the generator is empty, it raises an error. This is different from the behavior of calling the Index constructor on an empty list. This is a regression since 0.19.2.