Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add new columns in Hail table? #3565

Open
iris-garden opened this issue May 6, 2024 · 0 comments
Open

How to add new columns in Hail table? #3565

iris-garden opened this issue May 6, 2024 · 0 comments
Labels
discourse migrated from discuss.hail.is

Comments

@iris-garden
Copy link
Owner

Note

The following post was exported from discuss.hail.is, a forum for asking questions about Hail which has since been deprecated.

(Nov 25, 2021 at 04:37) Gopi said:

Hi,
MatrixTable 's annotate_cols adds new column fields. Table 's annotate adds new row fields.

Is there any way to add a new column to the hail table? We tried the below code but its throwing the following error “TypeError: ‘Table’ object does not support item assignment”

Code: ht[‘esp6500siv2_all’] = ht[‘AA_AF’]+ht[‘EA_AF’]

Regards,
Gopi

(Nov 25, 2021 at 14:25) tpoterba said:

We try to avoid calling table fields “columns” because “column” has a particular meaning for matrix tables, and also often connotes homogenous kinds of data between columns.

The analog of a Pandas DataFrame ‘column’ is a table row field. annotate is exactly what you need here:

ht = ht.annotate(esp6500siv2_all = ht[‘AA_AF’]+ht[‘EA_AF’])

(Mar 12, 2024 at 13:02) jjfarrell said:

Is there a way to specify the location of the new fields? For example, creating FID and IID fields to place in the first 2 collumns of the table. The default is to add them at the end.

(Mar 12, 2024 at 16:47) patrick-schultz said:

Generally we don’t consider the order of fields significant. Why do you want them first?

(Mar 12, 2024 at 17:10) danking said:

I assume you want this for export. I think the only way to achieve this is:

key = ht.key
ht = ht.key_by()
ht = ht.order_by(*key)
ht = ht.select(fields, in, the, order, you, want, ...)
ht.export(...)
@iris-garden iris-garden added the discourse migrated from discuss.hail.is label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discourse migrated from discuss.hail.is
Projects
None yet
Development

No branches or pull requests

1 participant