Skip to content

Commit c226f49

Browse files
committed
Permit any Mapping as source of DataFrame
1 parent dcb5494 commit c226f49

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pandas/core/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def __init__(
735735
raise ValueError("columns cannot be a set")
736736

737737
if copy is None:
738-
if isinstance(data, dict):
738+
if isinstance(data, Mapping):
739739
# retain pre-GH#38939 default behavior
740740
copy = True
741741
elif not isinstance(data, (Index, DataFrame, Series)):
@@ -754,7 +754,7 @@ def __init__(
754754
data, axes={"index": index, "columns": columns}, dtype=dtype, copy=copy
755755
)
756756

757-
elif isinstance(data, dict):
757+
elif isinstance(data, Mapping):
758758
# GH#38939 de facto copy defaults to False only in non-dict cases
759759
mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy)
760760
elif isinstance(data, ma.MaskedArray):

pandas/core/internals/construction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
if TYPE_CHECKING:
7878
from collections.abc import (
7979
Hashable,
80+
Mapping,
8081
Sequence,
8182
)
8283

@@ -347,7 +348,7 @@ def _check_values_indices_shape_match(
347348

348349

349350
def dict_to_mgr(
350-
data: dict,
351+
data: Mapping,
351352
index,
352353
columns,
353354
*,

0 commit comments

Comments
 (0)