diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d4ff1bc4f35ac..6e50d99449ed0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1914,11 +1914,11 @@ def from_dict( orient = orient.lower() # type: ignore[assignment] if orient == "index": if len(data) > 0: + index = list(data.keys()) # TODO speed up Series case if isinstance(next(iter(data.values())), (Series, dict)): data = _from_nested_dict(data) else: - index = list(data.keys()) # error: Incompatible types in assignment (expression has type # "List[Any]", variable has type "Dict[Any, Any]") data = list(data.values()) # type: ignore[assignment]