Fokko commented on issue #38615:
URL: https://github.com/apache/arrow/issues/38615#issuecomment-1879251134
Still running into this. I would expect something like below to work:
```python
In [1]: import pyarrow as pa
In [2]: current_schema = pa.schema([
...: ^Ipa.field("x", pa.float32()),
...: ^Ipa.field("y", pa.float32())
...: ])
...:
...: tbl = pa.Table.from_pylist(
...: [
...: {"x": 52.371807, "y": 4.896029},
...: {"x": 52.387386, "y": 4.646219},
...: {"x": 52.078663, "y": 4.288788},
...: ],
...: schema=current_schema,
...: )
...:
...: schema_with_z = pa.schema(
...: [
...: ^I^Ipa.field("x", pa.float32()),
...: ^I^Ipa.field("y", pa.float32()),
...: pa.field("x", pa.float32()),
...: ]
...: )
...:
...: tbl.cast(schema_with_z)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[2], line 23
6 tbl = pa.Table.from_pylist(
7 [
8 {"x": 52.371807, "y": 4.896029},
(...)
12 schema=current_schema,
13 )
15 schema_with_z = pa.schema(
16 [
17 pa.field("x", pa.float32()),
(...)
20 ]
21 )
---> 23 tbl.cast(schema_with_z)
File /opt/homebrew/lib/python3.11/site-packages/pyarrow/table.pxi:3793, in
pyarrow.lib.Table.cast()
ValueError: Target schema's field names are not matching the table's field
names: ['x', 'y'], ['x', 'y', 'x']
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]