Two-dimensional, size-mutable, potentially heterogeneous tabular data. Data structure also contains labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data
| 514 | |
| 515 | @set_module("pandas") |
| 516 | class DataFrame(NDFrame, OpsMixin): |
| 517 | """ |
| 518 | Two-dimensional, size-mutable, potentially heterogeneous tabular data. |
| 519 | |
| 520 | Data structure also contains labeled axes (rows and columns). |
| 521 | Arithmetic operations align on both row and column labels. Can be |
| 522 | thought of as a dict-like container for Series objects. The primary |
| 523 | pandas data structure. |
| 524 | |
| 525 | Parameters |
| 526 | ---------- |
| 527 | data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame |
| 528 | Dict can contain Series, arrays, constants, dataclass or list-like objects. If |
| 529 | data is a dict, column order follows insertion-order. If a dict contains Series |
| 530 | which have an index defined, it is aligned by its index. This alignment also |
| 531 | occurs if data is a Series or a DataFrame itself. Alignment is done on |
| 532 | Series/DataFrame inputs. |
| 533 | |
| 534 | If data is a list of dicts, column order follows insertion-order. |
| 535 | |
| 536 | index : Index or array-like |
| 537 | Index to use for resulting frame. Will default to RangeIndex if |
| 538 | no indexing information part of input data and no index provided. |
| 539 | columns : Index or array-like |
| 540 | Column labels to use for resulting frame when data does not have them, |
| 541 | defaulting to RangeIndex(0, 1, 2, ..., n). If data contains column labels, |
| 542 | will perform column selection instead. |
| 543 | dtype : dtype, default None |
| 544 | Data type to force. Only a single dtype is allowed. If None, infer. |
| 545 | If ``data`` is DataFrame then is ignored. |
| 546 | copy : bool or None, default None |
| 547 | Copy data from inputs. |
| 548 | For dict data, the default of None behaves like ``copy=True``. For DataFrame |
| 549 | or 2d ndarray input, the default of None behaves like ``copy=False``. |
| 550 | If data is a dict containing one or more Series (possibly of different dtypes), |
| 551 | ``copy=False`` will ensure that these inputs are not copied. |
| 552 | |
| 553 | See Also |
| 554 | -------- |
| 555 | DataFrame.from_records : Constructor from tuples, also record arrays. |
| 556 | DataFrame.from_dict : From dicts of Series, arrays, or dicts. |
| 557 | read_csv : Read a comma-separated values (csv) file into DataFrame. |
| 558 | read_table : Read general delimited file into DataFrame. |
| 559 | read_clipboard : Read text from clipboard into DataFrame. |
| 560 | |
| 561 | Notes |
| 562 | ----- |
| 563 | Please reference the :ref:`User Guide <basics.dataframe>` for more information. |
| 564 | |
| 565 | Examples |
| 566 | -------- |
| 567 | Constructing DataFrame from a dictionary. |
| 568 | |
| 569 | >>> d = {"col1": [1, 2], "col2": [3, 4]} |
| 570 | >>> df = pd.DataFrame(data=d) |
| 571 | >>> df |
| 572 | col1 col2 |
| 573 | 0 1 3 |