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。

 

上一篇:python数据分析——numpy创建多维数组的方式


下一篇:JVM内存模型