33
33
34
34
35
35
def from_dataframe (df , allow_copy = True ):
36
+ """
37
+ Build a ``pd.DataFrame`` from any DataFrame supporting the interchange protocol.
38
+
39
+ Parameters
40
+ ----------
41
+ df : DataFrameXchg
42
+ Object supporting the exchange protocol, i.e. `__dataframe__` method.
43
+ allow_copy : bool, default: True
44
+ Whether to allow copying the memory to perform the conversion
45
+ (if false then zero-copy approach is requested).
46
+
47
+ Returns
48
+ -------
49
+ pd.DataFrame
50
+ """
36
51
if isinstance (df , pd .DataFrame ):
37
52
return df
38
53
@@ -50,8 +65,9 @@ def _from_dataframe(df: DataFrameXchg, allow_copy=True):
50
65
----------
51
66
df : DataFrameXchg
52
67
Object supporting the exchange protocol, i.e. `__dataframe__` method.
53
- n_chunks : int, optional
54
- Number of chunks to split `df`.
68
+ allow_copy : bool, default: True
69
+ Whether to allow copying the memory to perform the conversion
70
+ (if false then zero-copy approach is requested).
55
71
56
72
Returns
57
73
-------
@@ -69,7 +85,7 @@ def _from_dataframe(df: DataFrameXchg, allow_copy=True):
69
85
if len (pandas_dfs ) == 1 :
70
86
pandas_df = pandas_dfs [0 ]
71
87
else :
72
- pandas_df = pd .concat (pandas_dfs , axis = 0 , ignore_index = True )
88
+ pandas_df = pd .concat (pandas_dfs , axis = 0 , ignore_index = True , copy = False )
73
89
74
90
index_obj = df .metadata .get ("pandas.index" , None )
75
91
if index_obj is not None :
0 commit comments