Open pmaier-bhs opened 5 months ago
It's unclear whether this is a documentation issue (should sequences of dicts be allowed in from_dict()
) or an implementation issue, where sequences of dicts should be rejected.
I agree with @Dr-Irv.
The function signature and type hints of from_dict()
indicates that data
should be a dict
, but in the code sample it also works when data
is a list of dict
s.
The discrepancy occurs because when executing the code example, from_dict()
passes data
to the DataFrame
class constructor, which accepts data
as a list of dict
s.
This does not raise an error in execution since Python runtime does not enforce type hints, but may cause issues with third-party tools.
I think there are two ways to fix this:
from_dict()
should accept a list of dict
s, the function's type hints and signature should be corrected to fit its behavior.from_dict()
to warn or raise an error when data
is passed as a list of dict
s.
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
By the documentation, and also by the signatures defined in pandas-stubs, from_dict should not parse
b
. But it does. Is this maybe deprecated behavior?See also https://github.com/pandas-dev/pandas-stubs/issues/929 and https://github.com/pandas-dev/pandas-stubs/issues/928
Expected Behavior
In accordance with documentation and type signatures (pandas-stubs), from_dict should reject processing
b
.Installed Versions