phpsxg commented on issue #35441:
URL: https://github.com/apache/arrow/issues/35441#issuecomment-1535901171
@mapleFU
I also have a question, how to automatically type conversion, for example,
id is int type, want to save is the string type, thank you
```
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('age', pa.int64(), metadata={b"table_field": b"AGE"})
])
data = {
"id": [i for i in range(3)],
"age": [random.randint(10, 30) for i in range(3)]
}
df = pd.DataFrame(data)
table = pa.Table.from_pandas(df,schema=schema)
file_path = 'test'
ds.write_dataset(table, file_path, format='parquet',
existing_data_behavior='delete_matching',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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]