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

Method read_row_group

python/pyarrow/parquet/core.py:436–481  ·  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

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

Calls 1

_get_column_indicesMethod · 0.95