|
36 | 36 |
|
37 | 37 |
|
38 | 38 | def from_dataframe(df : DataFrameObject,
|
39 |
| - allow_copy : bool = False) -> pd.DataFrame: |
| 39 | + allow_copy : bool = True) -> pd.DataFrame: |
40 | 40 | """
|
41 | 41 | Construct a pandas DataFrame from ``df`` if it supports ``__dataframe__``
|
42 | 42 | """
|
@@ -162,7 +162,7 @@ def convert_categorical_column(col : ColumnObject) -> pd.Series:
|
162 | 162 |
|
163 | 163 |
|
164 | 164 | def __dataframe__(cls, nan_as_null : bool = False,
|
165 |
| - allow_copy : bool = False) -> dict: |
| 165 | + allow_copy : bool = True) -> dict: |
166 | 166 | """
|
167 | 167 | The public method to attach to pd.DataFrame
|
168 | 168 |
|
@@ -195,11 +195,11 @@ class _PandasBuffer:
|
195 | 195 | Data in the buffer is guaranteed to be contiguous in memory.
|
196 | 196 | """
|
197 | 197 |
|
198 |
| - def __init__(self, x : np.ndarray, allow_copy : bool = False) -> None: |
| 198 | + def __init__(self, x : np.ndarray, allow_copy : bool = True) -> None: |
199 | 199 | """
|
200 | 200 | Handle only regular columns (= numpy arrays) for now.
|
201 | 201 | """
|
202 |
| - if allow_copy: |
| 202 | + if not allow_copy: |
203 | 203 | # Array is not contiguous and strided buffers do not need to be
|
204 | 204 | # supported. It brings some extra complexity for libraries that
|
205 | 205 | # don't support it (e.g. Arrow).
|
@@ -260,7 +260,7 @@ class _PandasColumn:
|
260 | 260 | """
|
261 | 261 |
|
262 | 262 | def __init__(self, column : pd.Series,
|
263 |
| - allow_copy : bool = False) -> None: |
| 263 | + allow_copy : bool = True) -> None: |
264 | 264 | """
|
265 | 265 | Note: doesn't deal with extension arrays yet, just assume a regular
|
266 | 266 | Series/ndarray for now.
|
@@ -496,7 +496,7 @@ class _PandasDataFrame:
|
496 | 496 | attributes defined on this class.
|
497 | 497 | """
|
498 | 498 | def __init__(self, df : pd.DataFrame, nan_as_null : bool = False,
|
499 |
| - allow_copy : bool = False) -> None: |
| 499 | + allow_copy : bool = True) -> None: |
500 | 500 | """
|
501 | 501 | Constructor - an instance of this (private) class is returned from
|
502 | 502 | `pd.DataFrame.__dataframe__`.
|
@@ -574,7 +574,7 @@ def test_noncontiguous_columns():
|
574 | 574 | df = pd.DataFrame(arr)
|
575 | 575 | assert df[0].to_numpy().strides == (24,)
|
576 | 576 | with pytest.raises(RuntimeError):
|
577 |
| - df2 = from_dataframe(df, allow_copy=True) |
| 577 | + df2 = from_dataframe(df, allow_copy=False) |
578 | 578 |
|
579 | 579 |
|
580 | 580 | def test_categorical_dtype():
|
|
0 commit comments