Build a ``pa.Table`` from the DataFrame interchange object. Parameters ---------- df : DataFrameObject Object supporting the interchange protocol, i.e. `__dataframe__` method. allow_copy : bool, default: True Whether to allow copying the memory to perfor
(df: DataFrameObject, allow_copy=True)
| 90 | |
| 91 | |
| 92 | def _from_dataframe(df: DataFrameObject, allow_copy=True): |
| 93 | """ |
| 94 | Build a ``pa.Table`` from the DataFrame interchange object. |
| 95 | |
| 96 | Parameters |
| 97 | ---------- |
| 98 | df : DataFrameObject |
| 99 | Object supporting the interchange protocol, i.e. `__dataframe__` |
| 100 | method. |
| 101 | allow_copy : bool, default: True |
| 102 | Whether to allow copying the memory to perform the conversion |
| 103 | (if false then zero-copy approach is requested). |
| 104 | |
| 105 | Returns |
| 106 | ------- |
| 107 | pa.Table |
| 108 | """ |
| 109 | batches = [] |
| 110 | for chunk in df.get_chunks(): |
| 111 | batch = protocol_df_chunk_to_pyarrow(chunk, allow_copy) |
| 112 | batches.append(batch) |
| 113 | |
| 114 | if not batches: |
| 115 | batch = protocol_df_chunk_to_pyarrow(df) |
| 116 | batches.append(batch) |
| 117 | |
| 118 | return pa.Table.from_batches(batches) |
| 119 | |
| 120 | |
| 121 | def protocol_df_chunk_to_pyarrow( |