Reputation: 1202
I have a pandas data frame which looks like the below:
Blast_ID Campaign Campaign ID Basic rate Market cost
ab12 Glass 20 220
ab34 Glass 234
ab56 Plastic 55 245
ab87 Plastic 10
I converted the columns with float64 data types into an integer with the following code( df being the data frame):
for i in df.columns:
print(i)
print(df[i].dtypes)
datatype = df[i].dtype
df = df.fillna(0)
if datatype == 'float64':
print('yes')
df[i] = df[i].astype(int)
Still when I am trying to upload this data frame into the dynamo DB with the following code:
myl_list = df1.T.to_dict().values()
print(myl_list)
#read the dynamo resource
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('VisData')
for Blast_ID in myl_list:
table.put_item(Item=Blast_ID)
Is it giving me error that:
"errorMessage": "Float types are not supported. Use Decimal types instead."
How can I solve that? Many Thanks
Upvotes: 1
Views: 3136
Reputation: 1460
Try casting into a string before putting in the table:
myl_list = df1.T.to_dict().values()
print(myl_list)
#read the dynamo resource
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('VisData')
for Blast_ID in myl_list:
table.put_item(Item=str(Blast_ID))
Upvotes: 1