You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Abderrahmane Jaidi (Jira)" <ji...@apache.org> on 2021/09/02 13:58:00 UTC
[jira] [Commented] (ARROW-13784) [Python] Table.from_arrays should
raise an error when array is empty but names is not
[ https://issues.apache.org/jira/browse/ARROW-13784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17408853#comment-17408853 ]
Abderrahmane Jaidi commented on ARROW-13784:
--------------------------------------------
Thanks [~jorisvandenbossche], wouldn't raising an error be a breaking change to users though? Code that was returning a table with an empty schema is now suddenly raising an error
> [Python] Table.from_arrays should raise an error when array is empty but names is not
> -------------------------------------------------------------------------------------
>
> Key: ARROW-13784
> URL: https://issues.apache.org/jira/browse/ARROW-13784
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Affects Versions: 4.0.1
> Reporter: Abderrahmane Jaidi
> Priority: Major
> Labels: good-first-issue
>
> The `Table.from_arrays` method returns an empty schema when supplying an empty arrays list but providing column names. As a result, the subsequent `to_pandas` method returns an empty data frame with no column names.
> ```
> {{import pyarrow as pa}}
> {{arrays = []}}
> {{cols_names = ["col1", "col2"]}}
> {{table = pa.Table.from_arrays(arrays=arrays, names=cols_names)}}
> {{table.schema # returns nothing}}
> {{df = table.to_pandas()}}
> {{df.head()}}
> {{Empty DataFrame
> Columns: []
> Index: [] # Expected column names to be visible here}}
> ```
> I assume that this is because a schema cannot be built without data types?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)