MCPcopy Create free account
hub / github.com/apache/arrow / read

Method read

python/pyarrow/parquet/core.py:605–649  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Calls 1

_get_column_indicesMethod · 0.95