You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Antoine Pitrou (Jira)" <ji...@apache.org> on 2021/02/08 12:47:00 UTC

[jira] [Commented] (ARROW-11553) [Python] Make Table.cast(schema) more flexible regarding order of fields / missing fields?

    [ https://issues.apache.org/jira/browse/ARROW-11553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17281010#comment-17281010 ] 

Antoine Pitrou commented on ARROW-11553:
----------------------------------------

Such options could be added to {{CastOptions}} I guess.

> [Python] Make Table.cast(schema) more flexible regarding order of fields / missing fields?
> ------------------------------------------------------------------------------------------
>
>                 Key: ARROW-11553
>                 URL: https://issues.apache.org/jira/browse/ARROW-11553
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Joris Van den Bossche
>            Priority: Major
>
> Currently, {{Table.cast}} requires a new schema with exactly the same names and same order of those names (it simply does a {{self.schema.names != target_schema.names: raise ...}} check). Example:
> {code:python}
> >>> table = pa.table({'a': [1, 2, 3], 'b': [.1, .2, .3]})
> >>> table
> pyarrow.Table
> a: int64
> b: double
> >>> schema = pa.schema([('a', pa.int32()), ('b', pa.float32())])
> >>> table.cast(schema)
> pyarrow.Table
> a: int32
> b: float
> >>> schema2 = pa.schema([('b', pa.float32()), ('a', pa.int32())])
> >>> table.cast(schema2)
> ....
> ValueError: Target schema's field names are not matching the table's field names: ['a', 'b'], ['b', 'a']
> {code}
> Do we want to make this more flexible? Allow different order? (and the follow order of the passed schema or of the original table?) Allow missing fields? (and then use the fields of the schema to "subset" as well?)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)