@@ -472,8 +472,12 @@ class DataFrame(NDFrame, OpsMixin):
472
472
Index to use for resulting frame. Will default to RangeIndex if
473
473
no indexing information part of input data and no index provided.
474
474
columns : Index or array-like
475
- Column labels to use for resulting frame. Will default to
476
- RangeIndex (0, 1, 2, ..., n) if no column labels are provided.
475
+ Columns to select from data or column labels to use for resulting frame.
476
+ Will use the provided labels for the column index if data does not
477
+ include column labels, defaulting to RangeIndex(0, 1, 2, ..., n).
478
+ If data does include column labels, will select the columns from data matching
479
+ with the provided labels to include in the frame, defaulting to
480
+ all columns.
477
481
dtype : dtype, default None
478
482
Data type to force. Only a single dtype is allowed. If None, infer.
479
483
copy : bool, default False
@@ -522,6 +526,16 @@ class DataFrame(NDFrame, OpsMixin):
522
526
0 1 2 3
523
527
1 4 5 6
524
528
2 7 8 9
529
+
530
+ >>> d = np.array([(1, 2, 3), (4, 5, 6), (7, 8, 9)],
531
+ dtype=[("a", "i4"), ("b", "i4"), ("c", "i4")])
532
+ >>> df3 = pd.DataFrame(d, columns=['c', 'a'])
533
+ ...
534
+ >>> df3
535
+ c a
536
+ 0 3 1
537
+ 1 6 4
538
+ 2 9 7
525
539
526
540
Constructing DataFrame from dataclass:
527
541
0 commit comments