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

Method read_row_groups

python/pyarrow/parquet/core.py:486–532  ·  view source on GitHub ↗

Read a multiple row groups from a Parquet file. Parameters ---------- row_groups : list Only these row groups will be read from the file. columns : list If not None, only these columns will be read from the row group. A co

(self, row_groups, columns=None, use_threads=True,
                        use_pandas_metadata=False)

Source from the content-addressed store, hash-verified

484 use_threads=use_threads)
485
486 def read_row_groups(self, row_groups, columns=None, use_threads=True,
487 use_pandas_metadata=False):
488 """
489 Read a multiple row groups from a Parquet file.
490
491 Parameters
492 ----------
493 row_groups : list
494 Only these row groups will be read from the file.
495 columns : list
496 If not None, only these columns will be read from the row group. A
497 column name may be a prefix of a nested field, e.g. 'a' will select
498 'a.b', 'a.c', and 'a.d.e'.
499 use_threads : bool, default True
500 Perform multi-threaded column reads.
501 use_pandas_metadata : bool, default False
502 If True and file has custom pandas schema metadata, ensure that
503 index columns are also loaded.
504
505 Returns
506 -------
507 pyarrow.table.Table
508 Content of the row groups as a table (of columns).
509
510 Examples
511 --------
512 >>> import pyarrow as pa
513 >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
514 ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
515 ... "Brittle stars", "Centipede"]})
516 >>> import pyarrow.parquet as pq
517 >>> pq.write_table(table, 'example.parquet')
518 >>> parquet_file = pq.ParquetFile('example.parquet')
519
520 >>> parquet_file.read_row_groups([0,0])
521 pyarrow.Table
522 n_legs: int64
523 animal: string
524 ----
525 n_legs: [[2,2,4,4,5,...,2,4,4,5,100]]
526 animal: [["Flamingo","Parrot","Dog",...,"Brittle stars","Centipede"]]
527 """
528 column_indices = self._get_column_indices(
529 columns, use_pandas_metadata=use_pandas_metadata)
530 return self.reader.read_row_groups(row_groups,
531 column_indices=column_indices,
532 use_threads=use_threads)
533
534 def iter_batches(self, batch_size=65536, row_groups=None, columns=None,
535 use_threads=True, use_pandas_metadata=False):

Calls 1

_get_column_indicesMethod · 0.95