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)
| 123 | |
| 124 | |
| 125 | def 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): |