Skip to content

Commit

Permalink
DOC: erroneous initialization of a DataFrame with Series objects #42818
Browse files Browse the repository at this point in the history
… (#42960)

* BUG: erroneous initialization of a DataFrame with Series objects #42818

* Modify: NaN is float object

* Modify: decrease objects

* Modify: format :

* Modify: start index from 0

* Modify: grammar error

* Modify: singular -> plural
  • Loading branch information
tyuyoshi authored Sep 8, 2021
1 parent 5018d20 commit 6e06f89
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]]),
Expand Down

0 comments on commit 6e06f89

Please sign in to comment.