Skip to content

BUG: from_dataframe with empty objects #53161

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

Merged
merged 4 commits into from
May 15, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added Arrow pyarrow functionality Interchange Dataframe Interchange Protocol labels May 9, 2023
@mroeschke mroeschke added this to the 2.1 milestone May 9, 2023
@@ -79,7 +79,9 @@ def _from_dataframe(df: DataFrameXchg, allow_copy: bool = True):
raise RuntimeError(
"To join chunks a copy is required which is forbidden by allow_copy=False"
)
if len(pandas_dfs) == 1:
if not pandas_dfs:
pandas_df = pd.DataFrame({col: [] for col in df.column_names()})
Copy link
Member

Choose a reason for hiding this comment

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

do we care about the dtype(s)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. Using protocol_df_chunk_to_pandas here will preserve the dtypes

@mroeschke
Copy link
Member Author

Going to merge, but happy to address any followups.

@mroeschke mroeschke merged commit 4f88a2a into pandas-dev:main May 15, 2023
@mroeschke mroeschke deleted the bug/interchange/empty branch May 15, 2023 20:36
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
* BUG: from_dataframe with empty objects

* Use protocol_df_chunk_to_pandas
topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 22, 2023
* BUG: from_dataframe with empty objects

* Use protocol_df_chunk_to_pandas
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* BUG: from_dataframe with empty objects

* Use protocol_df_chunk_to_pandas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Interchange Dataframe Interchange Protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Can't interchange zero-sized dataframes with Arrow
2 participants