问题介绍

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

我猜测也是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. Java基础---JavaJShell脚本工具

    JShell脚本工具是JDK9的新特性 什么时候会用到 JShell 工具呢,当我们编写的代码非常少的时候,而又不愿意编写类,main方法,也不愿意去编译和运行,这个时候可以使用JShell工具. 启 ...

  2. 【C++札记】new和delete

    介绍 1.malloc,free和new,delete区别. a.malloc,free是C/C++的标准库函数.new,delete是c++的操作符. b.malloc申请的是内存,严格意义不是&q ...

  3. Echarts API说明文档

    theme = {        // 全图默认背景        // backgroundColor: 'rgba(0,0,0,0)',                // 默认色板        ...

  4. Spring cloud的各类组件

    Spring cloud 的各类组件 1.注册中心 eureka 2.ribbon 3.feign 4.hystirx 断路器 5.高速缓存器 redis 6.断路器Dashboard监控仪表盘

  5. java实现带过期时间的缓存

    private static ScheduledExecutorService swapExpiredPool = new ScheduledThreadPoolExecutor(10); priva ...

  6. MD5加密处理

    无论传送过程和存储方式,都是以明文的方式,很不安全!一旦泄漏,将会造成很大的损失! 插件名称jQuery.MD5.js: /** * jQuery MD5 hash algorithm functio ...

  7. (七)springmvc之ModelAttribute注解

    一.没有使用@ModelAttribute的Controller方法. @RequestMapping("/save") public String save(User user) ...

  8. 【转载】使用appium遇到的坑

    问题 1. error: Failed to start an Appium session, err was: Error: Requested a new session but one was ...

  9. Html Agility Pack 使用 XPath 选择器

    想做一个爬虫程序,以前用的一直使用CSS选择器的html解析插件,最近做的项目想使用 Html Agility Pack 来做解析 Html Agility Pack使用 XPath 和 Linq 来 ...

  10. Quartz任务调度:MisFire策略和源码分析

    Quartz是为大家熟知的任务调度框架,先看看官网的介绍: ---------------------------------------------------------------------- ...