Python-TypeError:类型为'int64'的对象不是JSON可序列化的 [英] Python - TypeError: Object of type 'int64' is not JSON serializable
本文介绍了Python-TypeError:类型为'int64'的对象不是JSON可序列化的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据框,用于存储商店名称和每日销售额.我正在尝试使用下面的Python脚本将此内容插入到Salesforce中.但是,出现以下错误:
I have a data frame that stores store name and daily sales count. I am trying to insert this to Salesforce using the Python script below. However, I get the following error:
TypeError: Object of type 'int64' is not JSON serializable
下面是数据框的视图.
Storename,Count
Store A,10
Store B,12
Store C,5
我使用以下代码将其插入Salesforce.
I use the following code to insert it to Salesforce.
update_list = []
for i in range(len(store)):
update_data = {
'name': store['entity_name'].iloc[i],
'count__c': store['count'].iloc[i]
}
update_list.append(update_data)
sf_data_cursor = sf_datapull.salesforce_login()
sf_data_cursor.bulk.Account.update(update_list)
执行上面的最后一行时得到错误.有人可以协助解决此问题吗?谢谢.
Getting the error, when the last line above gets executed. Could anyone assist in fixing this? Thanks..
推荐答案
json
无法识别NumPy数据类型.在序列化对象之前将数字转换为Python int
:
json
does not recognize NumPy data types. Convert the number to a Python int
before serializing the object:
'count__c': int(store['count'].iloc[i])
这篇关于Python-TypeError:类型为'int64'的对象不是JSON可序列化的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文