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

Class FeatherDataset

python/pyarrow/feather.py:31–103  ·  view source on GitHub ↗

Encapsulates details of reading a list of Feather files. .. deprecated:: 24.0.0 Use :func:`pyarrow.dataset.dataset` with ``format='ipc'`` instead. Parameters ---------- path_or_paths : List[str] A list of file names validate_schema : bool, default True

Source from the content-addressed store, hash-verified

29
30
31class FeatherDataset:
32 """
33 Encapsulates details of reading a list of Feather files.
34
35 .. deprecated:: 24.0.0
36 Use :func:`pyarrow.dataset.dataset` with ``format='ipc'`` instead.
37
38 Parameters
39 ----------
40 path_or_paths : List[str]
41 A list of file names
42 validate_schema : bool, default True
43 Check that individual file schemas are all the same / compatible
44 """
45
46 def __init__(self, path_or_paths, validate_schema=True):
47 warnings.warn(
48 "pyarrow.feather.FeatherDataset is deprecated as of 24.0.0. "
49 "Use pyarrow.dataset.dataset() with format='ipc' instead.",
50 FutureWarning,
51 stacklevel=2
52 )
53 self.paths = path_or_paths
54 self.validate_schema = validate_schema
55
56 def read_table(self, columns=None):
57 """
58 Read multiple feather files as a single pyarrow.Table
59
60 Parameters
61 ----------
62 columns : List[str]
63 Names of columns to read from the file
64
65 Returns
66 -------
67 pyarrow.Table
68 Content of the file as a table (of columns)
69 """
70 _fil = _read_table_internal(self.paths[0], columns=columns)
71 self._tables = [_fil]
72 self.schema = _fil.schema
73
74 for path in self.paths[1:]:
75 table = _read_table_internal(path, columns=columns)
76 if self.validate_schema:
77 self.validate_schemas(path, table)
78 self._tables.append(table)
79 return concat_tables(self._tables)
80
81 def validate_schemas(self, piece, table):
82 if not self.schema.equals(table.schema):
83 raise ValueError(f'Schema in {piece} was different. \n'
84 f'{self.schema}\n\nvs\n\n{table.schema}')
85
86 def read_pandas(self, columns=None, use_threads=True):
87 """
88 Read multiple Parquet files as a single pandas DataFrame

Callers 2

test_datasetFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_datasetFunction · 0.72