DataFrame.itertuples() incorrectly determines when plain tuples should be used #28282
Labels
Regression
Functionality that used to work in a prior pandas version
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Milestone
Code Sample, a copy-pastable example if possible
The issue seems to have been caused/revealed by this commit that removed the try-catch block around the namedtuple class creation.
FWIW, this issue is not reproducible in version
0.24.2
, and is also not a problem in Python 3.7+, as the limit of the max number of arguments that can be passed to a function has been removed (AFAIK).Problem description
The condition in
itertuples()
method does not correctly determine when plain tuples should be used instead of named tuples.This how the named tuple class template defines the
__new__()
method (in Python 3.6 at least):If there are 255 column names given, the total number of arguments to
__new__()
will be 256, because of that extracls
, causing a syntax error.The text was updated successfully, but these errors were encountered: