Skip to content

Commit 8e16c7b

Browse files
minat-hubnoatamir
authored andcommitted
DOC: Updates to documentation (pandas-dev#49278)
* issue pandas-dev#48674 index constructor updates to the frame.py file * remove pandas-env in gitignore file and print from frame.py * remove blank line before closing docstring * reduce character count in changes made
1 parent 02e97fa commit 8e16c7b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pandas/core/frame.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ class DataFrame(NDFrame, OpsMixin):
490490
data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame
491491
Dict can contain Series, arrays, constants, dataclass or list-like objects. If
492492
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
494+
occurs if data is a Series or a DataFrame itself. Alignment is done on
495+
Series/DataFrame inputs.
494496
495497
.. versionchanged:: 0.25.0
496498
If data is a list of dicts, column order follows insertion-order.
@@ -592,6 +594,22 @@ class DataFrame(NDFrame, OpsMixin):
592594
0 0 0
593595
1 0 3
594596
2 2 3
597+
598+
Constructing DataFrame from Series/DataFrame:
599+
600+
>>> ser = pd.Series([1, 2, 3], index=["a", "b", "c"])
601+
>>> df = pd.DataFrame(data=ser, index=["a", "c"])
602+
>>> df
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+
>>> df2
610+
x
611+
a 1
612+
c 3
595613
"""
596614

597615
_internal_names_set = {"columns", "index"} | NDFrame._internal_names_set

0 commit comments

Comments
 (0)