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

Function write_feather

python/pyarrow/feather.py:125–217  ·  view source on GitHub ↗

Write a pandas.DataFrame to Feather format. .. deprecated:: 24.0.0 Use :func:`pyarrow.ipc.new_file` / :class:`pyarrow.ipc.RecordBatchFileWriter` instead. Feather V2 is the Arrow IPC file format. Parameters ---------- df : pandas.DataFrame or pyarrow.Table

(df, dest, compression=None, compression_level=None,
                  chunksize=None, version=2)

Source from the content-addressed store, hash-verified

123
124
125def write_feather(df, dest, compression=None, compression_level=None,
126 chunksize=None, version=2):
127 """
128 Write a pandas.DataFrame to Feather format.
129
130 .. deprecated:: 24.0.0
131 Use :func:`pyarrow.ipc.new_file` /
132 :class:`pyarrow.ipc.RecordBatchFileWriter` instead.
133 Feather V2 is the Arrow IPC file format.
134
135 Parameters
136 ----------
137 df : pandas.DataFrame or pyarrow.Table
138 Data to write out as Feather format.
139 dest : str
140 Local destination path.
141 compression : string, default None
142 Can be one of {"zstd", "lz4", "uncompressed"}. The default of None uses
143 LZ4 for V2 files if it is available, otherwise uncompressed.
144 compression_level : int, default None
145 Use a compression level particular to the chosen compressor. If None
146 use the default compression level
147 chunksize : int, default None
148 For V2 files, the internal maximum size of Arrow RecordBatch chunks
149 when writing the Arrow IPC file format. None means use the default,
150 which is currently 64K
151 version : int, default 2
152 Feather file version. Version 2 is the current. Version 1 is the more
153 limited legacy format
154 """
155 warnings.warn(
156 "pyarrow.feather.write_feather is deprecated as of 24.0.0. "
157 "Use pyarrow.ipc.new_file() / RecordBatchFileWriter instead. "
158 "Feather V2 is the Arrow IPC file format.",
159 FutureWarning,
160 stacklevel=2
161 )
162 if _pandas_api.have_pandas:
163 if (_pandas_api.has_sparse and
164 isinstance(df, _pandas_api.pd.SparseDataFrame)):
165 df = df.to_dense()
166
167 if _pandas_api.is_data_frame(df):
168 # Feather v1 creates a new column in the resultant Table to
169 # store index information if index type is not RangeIndex
170
171 if version == 1:
172 preserve_index = False
173 elif version == 2:
174 preserve_index = None
175 else:
176 raise ValueError("Version value should either be 1 or 2")
177
178 table = Table.from_pandas(df, preserve_index=preserve_index)
179
180 if version == 1:
181 # Version 1 does not chunking
182 for i, name in enumerate(table.schema.names):

Callers 15

_check_pandas_roundtripFunction · 0.90
_check_arrow_roundtripFunction · 0.90
fFunction · 0.90
test_datasetFunction · 0.90
test_read_tableFunction · 0.90
test_use_threadsFunction · 0.90
test_overwritten_fileFunction · 0.90
test_filelike_objectsFunction · 0.90
test_v2_set_chunksizeFunction · 0.90

Calls 2

check_chunked_overflowFunction · 0.85
lenFunction · 0.85

Tested by 15

_check_pandas_roundtripFunction · 0.72
_check_arrow_roundtripFunction · 0.72
fFunction · 0.72
test_datasetFunction · 0.72
test_read_tableFunction · 0.72
test_use_threadsFunction · 0.72
test_overwritten_fileFunction · 0.72
test_filelike_objectsFunction · 0.72
test_v2_set_chunksizeFunction · 0.72