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

Method read_row_group

python/pyarrow/parquet/core.py:439–484  ·  view source on GitHub ↗

Read a single row group from a Parquet file. Parameters ---------- i : int Index of the individual row group that we want to read. columns : list If not None, only these columns will be read from the row group. A column na

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

Source from the content-addressed store, hash-verified

437 return self.reader.closed
438
439 def read_row_group(self, i, columns=None, use_threads=True,
440 use_pandas_metadata=False):
441 """
442 Read a single row group from a Parquet file.
443
444 Parameters
445 ----------
446 i : int
447 Index of the individual row group that we want to read.
448 columns : list
449 If not None, only these columns will be read from the row group. A
450 column name may be a prefix of a nested field, e.g. 'a' will select
451 'a.b', 'a.c', and 'a.d.e'.
452 use_threads : bool, default True
453 Perform multi-threaded column reads.
454 use_pandas_metadata : bool, default False
455 If True and file has custom pandas schema metadata, ensure that
456 index columns are also loaded.
457
458 Returns
459 -------
460 pyarrow.table.Table
461 Content of the row group as a table (of columns)
462
463 Examples
464 --------
465 >>> import pyarrow as pa
466 >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
467 ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
468 ... "Brittle stars", "Centipede"]})
469 >>> import pyarrow.parquet as pq
470 >>> pq.write_table(table, 'example.parquet')
471 >>> parquet_file = pq.ParquetFile('example.parquet')
472
473 >>> parquet_file.read_row_group(0)
474 pyarrow.Table
475 n_legs: int64
476 animal: string
477 ----
478 n_legs: [[2,2,4,4,5,100]]
479 animal: [["Flamingo","Parrot",...,"Brittle stars","Centipede"]]
480 """
481 column_indices = self._get_column_indices(
482 columns, use_pandas_metadata=use_pandas_metadata)
483 return self.reader.read_row_group(i, column_indices=column_indices,
484 use_threads=use_threads)
485
486 def read_row_groups(self, row_groups, columns=None, use_threads=True,
487 use_pandas_metadata=False):

Calls 1

_get_column_indicesMethod · 0.95