Skip to content

Add copy keyword to to_dataframe #10345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7066,7 +7066,7 @@ def to_pandas(self) -> pd.Series | pd.DataFrame:
"Please use Dataset.to_dataframe() instead."
)

def _to_dataframe(self, ordered_dims: Mapping[Any, int]):
def _to_dataframe(self, ordered_dims: Mapping[Any, int], copy: bool = True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it needs to be added to the to_dataframe method

from xarray.core.extension_array import PandasExtensionArray

columns_in_order = [k for k in self.variables if k not in self.dims]
Expand Down Expand Up @@ -7104,6 +7104,7 @@ def _to_dataframe(self, ordered_dims: Mapping[Any, int]):
},
},
index=index,
copy=copy,
)
for extension_array_column in extension_array_columns_different_index:
extension_array = self.variables[extension_array_column].data
Expand Down
Loading