Skip to content

DOC: Clarify DataFrame column argument in API documentation #40658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,12 @@ class DataFrame(NDFrame, OpsMixin):
Index to use for resulting frame. Will default to RangeIndex if
no indexing information part of input data and no index provided.
columns : Index or array-like
Column labels to use for resulting frame. Will default to
RangeIndex (0, 1, 2, ..., n) if no column labels are provided.
Columns to select from data or column labels to use for resulting frame.
Will use the provided labels for the column index if data does not
include column labels, defaulting to RangeIndex(0, 1, 2, ..., n).
If data does include column labels, will select the columns from data matching
with the provided labels to include in the frame, defaulting to
all columns.
dtype : dtype, default None
Data type to force. Only a single dtype is allowed. If None, infer.
copy : bool, default False
Expand Down Expand Up @@ -523,6 +527,16 @@ class DataFrame(NDFrame, OpsMixin):
1 4 5 6
2 7 8 9

>>> d = np.array([(1, 2, 3), (4, 5, 6), (7, 8, 9)],
... dtype=[("a", "i4"), ("b", "i4"), ("c", "i4")])
>>> df3 = pd.DataFrame(d, columns=['c', 'a'])
...
>>> df3
c a
0 3 1
1 6 4
2 9 7

Constructing DataFrame from dataclass:

>>> from dataclasses import make_dataclass
Expand Down