apache / arrow

Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing
https://arrow.apache.org/
Apache License 2.0
14.33k stars 3.48k forks source link

[Python] Add Schema with_field or set_field method #42012

Open jorisvandenbossche opened 3 months ago

jorisvandenbossche commented 3 months ago

We have already have a Schema.with_metadata() method, and for Field we have with_metadata/with_name/with_type/with_nullable to create new fields from an existing one.

If you edit such a field, it would also be nice to have an easy way to update the Schema with that updated field, so that you could do something like this:

idx = 0
new_schema = schema.with_field(idx, schema.field(idx).with_nullable(False))

The with_.. mimics the other methods, although in this case it takes the index of the field to set, so a set_field() method might be a more fitting name (and then mimics Table.set_column)

knight42 commented 3 months ago

I would like to work on this, could you assign this issue to me?