Skip to content

Commit 7759d0f

Browse files
authored
dataframe dataclass docstring updated (#37632)
1 parent 8c170c4 commit 7759d0f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/core/frame.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class DataFrame(NDFrame, OpsMixin):
360360
Parameters
361361
----------
362362
data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame
363-
Dict can contain Series, arrays, constants, or list-like objects. If
363+
Dict can contain Series, arrays, constants, dataclass or list-like objects. If
364364
data is a dict, column order follows insertion-order.
365365
366366
.. versionchanged:: 0.25.0
@@ -420,6 +420,16 @@ class DataFrame(NDFrame, OpsMixin):
420420
0 1 2 3
421421
1 4 5 6
422422
2 7 8 9
423+
424+
Constructing DataFrame from dataclass:
425+
426+
>>> from dataclasses import make_dataclass
427+
>>> Point = make_dataclass("Point", [("x", int), ("y", int)])
428+
>>> pd.DataFrame([Point(0, 0), Point(0, 3), Point(2, 3)])
429+
x y
430+
0 0 0
431+
1 0 3
432+
2 2 3
423433
"""
424434

425435
_internal_names_set = {"columns", "index"} | NDFrame._internal_names_set

0 commit comments

Comments
 (0)