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

Function _from_dataframe

python/pyarrow/interchange/from_dataframe.py:92–118  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

90
91
92def _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
121def protocol_df_chunk_to_pyarrow(

Callers 5

test_pyarrow_roundtripFunction · 0.90
from_dataframeFunction · 0.85

Calls 3

get_chunksMethod · 0.45
appendMethod · 0.45