@@ -490,7 +490,8 @@ class DataFrame(NDFrame, OpsMixin):
490
490
data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame
491
491
Dict can contain Series, arrays, constants, dataclass or list-like objects. If
492
492
data is a dict, column order follows insertion-order. If a dict contains Series
493
- which have an index defined, it is aligned by its index.
493
+ which have an index defined, it is aligned by its index. This alignment also occurs
494
+ if data is a Series or a DataFrame itself. Alignment is done on Series/DataFrame inputs.
494
495
495
496
.. versionchanged:: 0.25.0
496
497
If data is a list of dicts, column order follows insertion-order.
@@ -592,6 +593,25 @@ class DataFrame(NDFrame, OpsMixin):
592
593
0 0 0
593
594
1 0 3
594
595
2 2 3
596
+
597
+ Constructing DataFrame from Series/DataFrame:
598
+
599
+ >>> ser = pd.Series([1, 2, 3], index=["a", "b", "c"])
600
+ >>> df = pd.DataFrame(data=ser, index=["a", "c"])
601
+ >>> print(df)
602
+
603
+ 0
604
+ a 1
605
+ c 3
606
+
607
+ >>> df1 = pd.DataFrame([1, 2, 3], index=["a", "b", "c"], columns=["x"])
608
+ >>> df2 = pd.DataFrame(data=df1, index=["a", "c"])
609
+ >>> print(df2)
610
+
611
+ x
612
+ a 1
613
+ c 3
614
+
595
615
"""
596
616
597
617
_internal_names_set = {"columns" , "index" } | NDFrame ._internal_names_set
0 commit comments