I'm trying to write a parquet file into s3 to run a Copy into Redshift/ Parquet file is being write correctly but I got an error when try to copy: Column type: DECIMAL(10,2), Parquet schema: optional doubl.
The error message is pretty clear but I'm not sure how to enforce a column to be Decimal type.
Is possible to do it? Keep column value as Decimal when write parquet?
from datetime import datetime
import pandas as pd
import decimal as D
import numpy as np
data = [
{
"name": "ted",
"timestamp": datetime.now().isoformat(),
"actual_data": "2019-06-28 00:00:00",
"age": 34,
"value": 0.10
},
{
"name": "barney",
"timestamp": datetime.now().isoformat(),
"actual_data": "2019-06-28 10:00:00",
"age": 35,
}
]
df = pd.DataFrame.from_dict(data,)
df['age'] = df['age'].astype(int)
df['value'] = df['value'].fillna(0)
df['value'] = df['value'].astype(np.float, 2)
# df_merged["id"] = df_merged["id"].astype(int)
print(df)
df.to_parquet(f"s3://awesome-parquet-test/data.parquet", index=False)