问题介绍

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

我猜测也是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. vue-cli webpack打包后加载资源的路径问题

    vue项目,访问打包后的项目,输入路径后,页面加载空白.这时会有两类问题,都是路径问题. 1.一个是css,js,ico等文件加载不到,是目录里少了dist 打开页面时一片空白 解决办法: confi ...

  2. Spring boot+Websocket实例1

    简单的demo https://github.com/callicoder/spring-boot-websocket-chat-demo

  3. c函数模板实现

    实现冒泡排序模板 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <str ...

  4. 系统集成Facebook授权发布帖子以及获取帖子评论等功能

    公司的业务和海外贸易紧密连接,项目中需要对接Facebook.Google.Twitter相关API,下面详细描述一下我们对接Facebook中遇到的问题 1,注册Facebook账户,Faceboo ...

  5. Python senium 中页面属性

    1.通过id定位元素2.通过class_name定位元素3.通过tag_name定位元素4.通过name定位元素5.通过link文字精确定位元素6.通过link文字模糊定位元素7.通过CSS定位元素8 ...

  6. 理解 is_callable

    官方解释: (PHP 4 >= 4.0.6, PHP 5, PHP 7) is_callable — 检测参数是否为合法的可调用结构. 说明 is_callable ( callable $na ...

  7. 安装本地jar包

    (1)安装在本地maven库 假设我们需要引入的包为 myjar-1.0.jar (1.1)打开cmd,进入myjar-1.0.jar所在的目录 (1.2)执行如下命令:mvn install:ins ...

  8. 部署java应用的几种方式

    J2EE应用 该应用根目录下有好多文件夹和以jsp结尾的文件 部署时,需要在tomcat的conf目录下的server.xml文件中添加上<Context path="/" ...

  9. (十)SpringBoot之web 应用开发-Servlets, Filters, listeners

    一.需求 Web 开发使用 Controller 基本上可以完成大部分需求,但是我们还可能会用到 Servlet. FilterListene 二.案例 2.1 通过注册 ServletRegistr ...

  10. ES6 Proise 简单理解

    Promise 这是ES6中增加的一个处理异步的对象. 传统变成写异步函数的时候,经常会遇到回调套回调: Promise 是异步编程的一种解决方案,比传统的解决方案 -----回调函数和事件----- ...