How do I drop a nested field?

I have a table that looks like this:

In [5]: t.describe()                                                                                                                                                                                                                                                                                                                                   
----------------------------------------
Global fields:
    None
----------------------------------------
Row fields:
    'idx': int32 
    'associations': struct {
        OR: float64, 
        beta: int32, 
        se: int32
    } 
----------------------------------------
Key: ['idx']
----------------------------------------

I want to drop the field t.associations.OR so that I can just export beta and se, how do I do that?

Great question!

In addition to Table.drop for dropping top-level fields, structs have StructExpression.drop:

t = t.annotate(associations = t.associations.drop('OR'))

You can repeat this pattern for deeper annotations. This drops associations.pheno1.OR:

t = t.annotate(associations =
    t.associations.annotate(pheno1 =
        t.associations.pheno1.drop('OR')))

As you can see it gets tiring to deal with nested annotations! It might be easier to read this way:

new_pheno1 = t.associations.pheno1.drop('OR')
new_associations = t.associations.annotate(pheno1 = new_pheno1)
t = t.annotate(associations = new_associations)

We generally recommend avoiding deeply nested annotations because of this complexity!