-
Notifications
You must be signed in to change notification settings - Fork 232
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
PyArrow: Pass in null-mask #1264
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
return pa.StructArray.from_arrays( | ||
arrays=field_arrays, | ||
fields=pa.struct(fields), | ||
mask=struct_array.is_null() if isinstance(struct_array, pa.StructArray) else None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyarrow_table: pa.Table = pa.Table.from_pylist(records, schema=schema) | ||
table.append(pyarrow_table) | ||
|
||
assert pyarrow_table.to_pandas()["struct_field_1"].tolist() == table.scan().to_pandas()["struct_field_1"].tolist() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the null masking is also done by pandas.
>>> pyarrow_table['struct_field_1']
<pyarrow.lib.ChunkedArray object at 0x10482c6d0>
[
-- is_valid:
[
false
]
-- child 0 type: string
[
""
]
-- child 1 type: int32
[
0
]
-- child 2 type: float
[
0
]
]
>>> pyarrow_table['struct_field_1'].to_pandas()
0 None
Name: struct_field_1, dtype: object
Thanks for the prompt review @kevinjqliu |
* PyArrow: Pass in null-mask * Add missing flag
* PyArrow: Pass in null-mask * Add missing flag
Fixes #1255