BUG: DataFrame constructor with UserList dataclass broken by upgrade to 1.1.0 #41682
Open
2 of 3 tasks
Labels
Bug
Constructors
Series/DataFrame/Index/pd.array Constructors
Regression
Functionality that used to work in a prior pandas version
Code Sample, a copy-pastable example
Problem description
I wrote code like this for pandas 1.0.5. When I upgraded to 1.2 my unittests started failing with
TypeError: asdict() should be called on dataclass instances
. PR #27999 and issue #21910 changed the behavior of the DataFrame constructor to treatdata
as all dataclasses if the first element is a dataclass. The behavior is documented but not quite what I'd like.Expected Output
Admittedly a esoteric case, but I'm documenting my upgrade issuse. In this case I think checking for
is_list_like(data[0])
beforeis_dataclass(data[0])
works better for me. Or maybe in hindsight from_dataclasses wasn't a bad idea.The text was updated successfully, but these errors were encountered: