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