[Python] Why are there still floats when trying to put an item in Dynamo DB even after using...

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página