问题介绍

打印了一下数据格式,并未发现问题。如果说是字典实例引起的。

我猜测也是extra字段引起的,因为extra字段是一个json字段。根据网上的提示要对这样的格式进行强转str.

其他发现:pd.to_sql操作还对我们的表进行了删除和重建(if_exists="replace"),改变了我们想要的mysql表数据格式。

可能是pd.df不支持json导致的。表的其他属性也没有被保留。

问题解决

方案:就是采用if_exists="append"的参数方案,在数据插入之前对表里的数据进行truncate table清空表内的数据。

对多单个列和多个列进行强转:

df['column1']=df['column1'].astype('float64')
df=df.astype({'column1':'float64','column2':str})

Pandas to_sql TypeError: sequence item 0: expected str instance, dict found的更多相关文章

  1. TypeError: sequence item 1: expected str instance, int found

    Error Msg Traceback (most recent call last): File "E:/code/adva_code/my_orm.py", line 108, ...

  2. TypeError: sequence item 0: expected string, Tag found

    原始代码: soup = BeautifulSoup(result, 'html.parser') content_list = soup.find_all('p', attrs={"cla ...

  3. org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua ...

  4. 20.org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua ...

  5. TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)

    报错: TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a str ...

  6. 关于Hibernate级联更新插入信息时提示主键不为空的问题“org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1 ”

    org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual ...

  7. TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)

    6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...

  8. 关于Error during managed flush [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]错误

    控制台报错: 08:07:09.293 [http-bio-8080-exec-2] ERROR org.hibernate.internal.SessionImpl - HHH000346: Err ...

  9. Python 读写文件 中文乱码 错误TypeError: write() argument must be str, not bytes+

    今天写上传文件代码,如下 def uploadHandle(request): pic1=request.FILES['pic1'] picName=os.path.join(settings.MED ...

随机推荐

  1. 20175316 盛茂淞 2018-2019-2 《Java程序设计》实验五 《网络安全与编程》 实验报告

    20175316 盛茂淞 2018-2019-2 <Java程序设计>实验五 <网络安全与编程> 实验报告 一.实验报告封面 课程:Java程序设计 班级:1753班 姓名:盛 ...

  2. Longest Line of Consecutive One in Matrix

    Given a 01 matrix, find the longest line of consecutive 1 in the matrix. The line could be horizonta ...

  3. python 脚本备份mssql数据库并删除数据库

    一.实现脚本 # -*- coding=utf-8 -*- import pyodbc from datetime import datetime import pymssql import os i ...

  4. Win10 鼠标右键新建菜单添加自定义文件

    1. 引言 在鼠标右键(右单机)新建菜单中添加自定义文件,例如:写字板,markdown等. 效果图: 2. 操作步骤(以Win10为例) 1. win+R输入regedit进入注册表 2. 这里以添 ...

  5. 某 游戏公司 php 面试题

    1.实现未知宽高元素的水平垂直居中,至少两种方法. <div, class="father"> <div class="son">< ...

  6. wordpress 图片上传时发生了错误,请稍后再试 的解决办法

    前一天网站还是好好的,仅一天过后就显示图片无法上传,百思不得其解 上下百度,大多数帖子提供的解决办法对我都不适用,继续搜,最后发现一篇帖子中提到是wp-config的编码格式问题 想到昨天刚好修改了下 ...

  7. Django导出数据为Excel,调用浏览器下载

    1. 环境 Django (2.1.10) + Python3.6 + xlwt (1.3.0) 操作系统使用的为:Windows 7 2. 接口代码 def now_export(request): ...

  8. gin PostForm 方法不起作用

    情景: 在httpie post 下,在 axios post下,总的来说,就是在form-data下只有c.Bind()会有用 如果一定要用c.PostForm() headers必须为x-www- ...

  9. SAS学习笔记8 循环语句(do函数)

    do-end函数

  10. MongoDB增删改

    一.数据库操作 显示现有的数据库,命令:show dbs 或者 databases; 示当前使用的数据库,命令:db 切换当前使用的数据库,命令:use 数据库名称 删除数据库,命令:db.dropD ...