pandas读取read_excel未设置dtype
作者:互联网
使用pandas读取excel
pd.read_excel(xlsx, sheetname='sheet1')则默认的数字读出来的格式是numpy.int64
直接存储到数据库会报错numpy.int64 cannot be converted
因此加上dtype
pd.read_excel(xlsx, sheetname='sheet1', dtype = str)
则都默认是str类型了
dtype 使用详细说明
dtype
:列的类型名称或字典,默认为None。数据或列的数据类型。例如{'a':np.float64,'b':np.int32}使用对象保存存储在Excel中的数据而不解释dtype。如果指定了转换器,则它们将应用于dtype转换的INSTEAD。
标签:read,dtype,excel,默认,sheetname,sheet1 来源: https://www.cnblogs.com/atagirl/p/14475260.html