diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f5090097f72d8..304de0a00cded 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -469,7 +469,8 @@ class DataFrame(NDFrame, OpsMixin): ---------- data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame Dict can contain Series, arrays, constants, dataclass or list-like objects. If - data is a dict, column order follows insertion-order. + data is a dict, column order follows insertion-order. If a dict contains Series + which have an index defined, it is aligned by its index. .. versionchanged:: 0.25.0 If data is a list of dicts, column order follows insertion-order. @@ -524,6 +525,16 @@ class DataFrame(NDFrame, OpsMixin): col2 int8 dtype: object + Constructing DataFrame from a dictionary including Series: + + >>> d = {'col1': [0, 1, 2, 3], 'col2': pd.Series([2, 3], index=[2, 3])} + >>> pd.DataFrame(data=d, index=[0, 1, 2, 3]) + col1 col2 + 0 0 NaN + 1 1 NaN + 2 2 2.0 + 3 3 3.0 + Constructing DataFrame from numpy ndarray: >>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),