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