You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "phpsxg (via GitHub)" <gi...@apache.org> on 2023/05/05 06:47:29 UTC
[GitHub] [arrow] phpsxg commented on issue #35441: How to define that a field can be null
phpsxg commented on issue #35441:
URL: https://github.com/apache/arrow/issues/35441#issuecomment-1535794081
> Seems default of nullable is true ( https://arrow.apache.org/docs/python/generated/pyarrow.field.html#pyarrow.field ). What error does it report? And can you provide how to reproduce the error?
```
import random
import pandas as pd
import pyarrow as pa
import pyarrow.dataset as ds
schema = pa.schema([
pa.field('id', pa.string(), metadata={b"table_field": b"ID"}),
pa.field('name', pa.string(), metadata={b"table_field": b"NAME"}),
pa.field('age', pa.int8(), metadata={b"table_field": b"AGE"})
])
data = {
"id": [i for i in range(3)],
"name": [None] * 3,
"age": [random.randint(10, 30) for i in range(3)]
}
df = pd.DataFrame(data)
print(df)
table = pa.Table.from_pandas(df)
file_path = 'test'
ds.write_dataset(table, file_path, format='parquet', schema=schema)
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org