Open pmaier-bhs opened 6 months ago
Btw. the following example works, i.e. shows no issue:
b = [
{"key1": "value1", "key2": 42},
{"key1": "value2", "key2": 123},
]
df = pd.DataFrame.from_dict(b) # type: ignore
i: int = df.shape[0]
You wrote:
The
DataFrame.from_dict()
method allows parsing lists of dictionaries
If I look at the docs https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.from_dict.html , it doesn't say that a list of dict
is allowed. So while that may work, that may be a pandas bug or a documentation bug. Can you create an issue in pandas
about the docs of to_dict()
and see what the pandas core team has to say?
Related to #929 .
You wrote:
The
DataFrame.from_dict()
method allows parsing lists of dictionariesIf I look at the docs https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.from_dict.html , it doesn't say that a list of
dict
is allowed. So while that may work, that may be a pandas bug or a documentation bug. Can you create an issue inpandas
about the docs ofto_dict()
and see what the pandas core team has to say?
Sure!
Created a pandas issue, see https://github.com/pandas-dev/pandas/issues/58862.
Describe the bug The
DataFrame.from_dict()
method allows parsing lists of dictionaries, where each dictionary is interpreted as a single row. However, this behavior is not reflected in the typed method signatures coded in pandas-stubs. We use that behavior and add# type: ignore
comments to suppress mypy errors.This worked without issue up until pandas-stubs version 2.2.1.240316, but with the update to version 2.2.2.240514, it leads to unexpected mypy failures, see below. The specific change responsible might be this commit.
To Reproduce
pandas
example that is not properly checked by the stubs.mypy
orpyright
).mypy
Please complete the following information:
pandas-stubs
: 2.2.2.240514