Read a Table from Parquet format. Parameters ---------- columns : list If not None, only these columns will be read from the file. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e'.
(self, columns=None, use_threads=True, use_pandas_metadata=False)
| 597 | return batches |
| 598 | |
| 599 | def read(self, columns=None, use_threads=True, use_pandas_metadata=False): |
| 600 | """ |
| 601 | Read a Table from Parquet format. |
| 602 | |
| 603 | Parameters |
| 604 | ---------- |
| 605 | columns : list |
| 606 | If not None, only these columns will be read from the file. A |
| 607 | column name may be a prefix of a nested field, e.g. 'a' will select |
| 608 | 'a.b', 'a.c', and 'a.d.e'. |
| 609 | use_threads : bool, default True |
| 610 | Perform multi-threaded column reads. |
| 611 | use_pandas_metadata : bool, default False |
| 612 | If True and file has custom pandas schema metadata, ensure that |
| 613 | index columns are also loaded. |
| 614 | |
| 615 | Returns |
| 616 | ------- |
| 617 | pyarrow.table.Table |
| 618 | Content of the file as a table (of columns). |
| 619 | |
| 620 | Examples |
| 621 | -------- |
| 622 | Generate an example Parquet file: |
| 623 | |
| 624 | >>> import pyarrow as pa |
| 625 | >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100], |
| 626 | ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse", |
| 627 | ... "Brittle stars", "Centipede"]}) |
| 628 | >>> import pyarrow.parquet as pq |
| 629 | >>> pq.write_table(table, 'example.parquet') |
| 630 | >>> parquet_file = pq.ParquetFile('example.parquet') |
| 631 | |
| 632 | Read a Table: |
| 633 | |
| 634 | >>> parquet_file.read(columns=["animal"]) |
| 635 | pyarrow.Table |
| 636 | animal: string |
| 637 | ---- |
| 638 | animal: [["Flamingo","Parrot",...,"Brittle stars","Centipede"]] |
| 639 | """ |
| 640 | column_indices = self._get_column_indices( |
| 641 | columns, use_pandas_metadata=use_pandas_metadata) |
| 642 | return self.reader.read_all(column_indices=column_indices, |
| 643 | use_threads=use_threads) |
| 644 | |
| 645 | def scan_contents(self, columns=None, batch_size=65536): |
| 646 | """ |