AlenkaF commented on issue #12458:
URL: https://github.com/apache/arrow/issues/12458#issuecomment-1044500102
You could also try to pass a schema to `to_parquet` if you know you have
strings for certain columns:
```python
import pandas as pd
import pyarrow as pa
dr = pd.date_range(start='2022-01-01', end='2022-01-10', freq='D')
df = pd.DataFrame(index=dr)
df['A'] = pd.to_datetime('today')
df['B'] = 1.0
df['C'] = 'a'
df['D'] = 2
schema = pa.schema([
pa.field('A', pa.timestamp('ns')),
pa.field('B', pa.float64()),
pa.field('C', pa.string()),
pa.field('D', pa.int64())])
df.head(0).to_parquet('b/0.parquet', schema=schema)
df.to_parquet('b/1.parquet')
pd.read_parquet('b')
A B C D
0 2022-02-18 14:03:36.691288 1.0 a 2
1 2022-02-18 14:03:36.691288 1.0 a 2
2 2022-02-18 14:03:36.691288 1.0 a 2
3 2022-02-18 14:03:36.691288 1.0 a 2
4 2022-02-18 14:03:36.691288 1.0 a 2
5 2022-02-18 14:03:36.691288 1.0 a 2
6 2022-02-18 14:03:36.691288 1.0 a 2
7 2022-02-18 14:03:36.691288 1.0 a 2
8 2022-02-18 14:03:36.691288 1.0 a 2
9 2022-02-18 14:03:36.691288 1.0 a 2
```
See https://issues.apache.org/jira/browse/ARROW-14488
--
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]