问题介绍

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

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

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

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

问题解决

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

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

  1. df['column1']=df['column1'].astype('float64')
  2. 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. AirFlow后台运行调度程序

    nohup airflow worker>>$AIRFLOW_HOME/airflow-worker.log >& & nohup airflow scheduler ...

  2. db2 数据库配置HADR+TSA添加集群节点

    Db2配置HADR高可用+TSA添加集群节点 一.服务器资源 Master IP:10.78.10.1 数据库:dbclassSlave IP:10.78.10.2 数据库:dbclassVIP:10 ...

  3. 纯java代码搭建ssm

    参考: https://blog.csdn.net/Smile__1/article/details/103394460

  4. springcloud断路器Dashboard监控仪表盘的使用

    断路器Dashboard监控仪表盘的使用 在原有的orderserverfeignhystrix服务中使用 1.增加依赖仓库              <dependency> <g ...

  5. SSH框架结合案例构建配置

    ssh框架概述 SSH是 struts+spring+hibernate的一个集成框架,是目前比较流行的一种Web应用程序开源框架.区别于 Secure Shell . 集成SSH框架的系统从职责上分 ...

  6. js 监听键盘的enter键

    // js 版本 window.onload=function(){ document.onkeydown=function(ev){ var event=ev ||event if(event.ke ...

  7. 本地虚拟机NAT模式下怎么设置才可以访问外网

    记:因为我要在本机虚拟机上安装Docker,结果发现虚拟机环境不能上网,是主机模式.我要调成net模式下才可以访问外网,这就需要怎么设置.下面文章记录一下. 在本机安装VMware软件后,系统中会自动 ...

  8. 在论坛中出现的比较难的sql问题:2(row_number函数+子查询)

    原文:在论坛中出现的比较难的sql问题:2(row_number函数+子查询) 2.如何去掉字段内的重复.

  9. JavaScript--关于闭包(closure)

    js代码在执行前会做的几件事情: 1.代码检测 2.预编译:在执行代码之前会对代码中的函数以及变量提前声明 并且做一些其他的处理 1.函数在执行前的一瞬间,会生成一个OA(object action) ...

  10. 关于reduce

    arr.reduce( callback,[initialValue]) reduce 为数组中的每一个元素依次执行回调函数,不包括数组中被删除或从未被赋值的元素 callback (执行数组中每个值 ...