@@ -472,8 +472,9 @@ 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
+ Column labels to use for resulting frame when data does not have them,
476
+ defaulting to RangeIndex(0, 1, 2, ..., n). If data contains column labels,
477
+ will perform column selection instead.
477
478
dtype : dtype, default None
478
479
Data type to force. Only a single dtype is allowed. If None, infer.
479
480
copy : bool or None, default None
@@ -527,6 +528,18 @@ class DataFrame(NDFrame, OpsMixin):
527
528
1 4 5 6
528
529
2 7 8 9
529
530
531
+ Constructing DataFrame from a numpy ndarray that has labeled columns:
532
+
533
+ >>> data = np.array([(1, 2, 3), (4, 5, 6), (7, 8, 9)],
534
+ ... dtype=[("a", "i4"), ("b", "i4"), ("c", "i4")])
535
+ >>> df3 = pd.DataFrame(data, columns=['c', 'a'])
536
+ ...
537
+ >>> df3
538
+ c a
539
+ 0 3 1
540
+ 1 6 4
541
+ 2 9 7
542
+
530
543
Constructing DataFrame from dataclass:
531
544
532
545
>>> from dataclasses import make_dataclass
0 commit comments