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

Function write_feather

python/pyarrow/feather.py:116–208  ·  view source on GitHub ↗

Write a pandas.DataFrame to Feather format. Parameters ---------- df : pandas.DataFrame or pyarrow.Table Data to write out as Feather format. dest : str Local destination path. compression : string, default None Can be one of {"zstd", "lz4", "uncompr

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

Source from the content-addressed store, hash-verified

114
115
116def write_feather(df, dest, compression=None, compression_level=None,
117 chunksize=None, version=2):
118 """
119 Write a pandas.DataFrame to Feather format.
120
121 Parameters
122 ----------
123 df : pandas.DataFrame or pyarrow.Table
124 Data to write out as Feather format.
125 dest : str
126 Local destination path.
127 compression : string, default None
128 Can be one of {"zstd", "lz4", "uncompressed"}. The default of None uses
129 LZ4 for V2 files if it is available, otherwise uncompressed.
130 compression_level : int, default None
131 Use a compression level particular to the chosen compressor. If None
132 use the default compression level
133 chunksize : int, default None
134 For V2 files, the internal maximum size of Arrow RecordBatch chunks
135 when writing the Arrow IPC file format. None means use the default,
136 which is currently 64K
137 version : int, default 2
138 Feather file version. Version 2 is the current. Version 1 is the more
139 limited legacy format.
140
141 .. deprecated:: 25.0.0
142 Writing Feather V1 files is deprecated. Use the default
143 ``version=2`` to write Arrow IPC files instead.
144 """
145 if version == 1:
146 warnings.warn(
147 "Feather V1 files are deprecated as of 25.0.0 and support will "
148 "be removed in a future version. Use the default version=2 to "
149 "write Arrow IPC files instead.",
150 DeprecationWarning,
151 stacklevel=2
152 )
153 if _pandas_api.have_pandas:
154 if (_pandas_api.has_sparse and
155 isinstance(df, _pandas_api.pd.SparseDataFrame)):
156 df = df.to_dense()
157
158 if _pandas_api.is_data_frame(df):
159 # Feather v1 creates a new column in the resultant Table to
160 # store index information if index type is not RangeIndex
161
162 if version == 1:
163 preserve_index = False
164 elif version == 2:
165 preserve_index = None
166 else:
167 raise ValueError("Version value should either be 1 or 2")
168
169 table = Table.from_pandas(df, preserve_index=preserve_index)
170
171 if version == 1:
172 # Version 1 does not chunking
173 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