Skip to content

Commit

Permalink
issue pandas-dev#48674 index constructor updates to the frame.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
minat-hub committed Oct 24, 2022
1 parent ee352b1 commit c25f3af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -121,6 +121,7 @@ doc/build/html/index.html
# Windows specific leftover:
doc/tmp.sv
env/
pandas-env
doc/source/savefig/

# Interactive terminal generated files #
Expand Down
22 changes: 21 additions & 1 deletion pandas/core/frame.py
Expand Up @@ -490,7 +490,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. If a dict contains Series
which have an index defined, it is aligned by its index.
which have an index defined, it is aligned by its index. This alignment also occurs
if data is a Series or a DataFrame itself. Alignment is done on Series/DataFrame inputs.
.. versionchanged:: 0.25.0
If data is a list of dicts, column order follows insertion-order.
Expand Down Expand Up @@ -592,6 +593,25 @@ class DataFrame(NDFrame, OpsMixin):
0 0 0
1 0 3
2 2 3
Constructing DataFrame from Series/DataFrame:
>>> ser = pd.Series([1, 2, 3], index=["a", "b", "c"])
>>> df = pd.DataFrame(data=ser, index=["a", "c"])
>>> print(df)
0
a 1
c 3
>>> df1 = pd.DataFrame([1, 2, 3], index=["a", "b", "c"], columns=["x"])
>>> df2 = pd.DataFrame(data=df1, index=["a", "c"])
>>> print(df2)
x
a 1
c 3
"""

_internal_names_set = {"columns", "index"} | NDFrame._internal_names_set
Expand Down

0 comments on commit c25f3af

Please sign in to comment.