Why are there still floats in this item I'm trying to put into DDB after parse_float?

Viewed 28

I have a dataframe that can have some columns that are numerical values (some are whole, some are not), and I need to get the data into AWS DynamoDB. DynamoDB isn't happy about floats and wants Decimals only.

I am currently doing:

results = formatted_df.T.to_dict().values()

with self.approval_table.batch_writer() as batch:
    for result in results:
        formatted_item = json.loads(json.dumps(result), parse_float=Decimal)
        batch.put_item(Item=formatted_item)

But with or without the json.loads(json.dumps(...),...) on put_item, I'm still getting Float types are not supported. Use Decimal types instead. I am not sure why, as I thought this was supposed to handle getting rid of the Float types.

Any help to figure out what I'm missing here would be greatly appreciated

0 Answers
Related