问题介绍

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

我猜测也是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. sqlserver2005版本的mdf文件,还没有log文件,

    https://www.cnblogs.com/wanglg/p/3740129.html  来自此文 仅做备忘  感谢提供信息让我处理好此问题 sqlserver mdf向上兼容附加数据库(无法打开 ...

  2. Java语言资源国际化步骤

    语言资源国际化步骤:   1. 定义资源文件(如:language),需要使用命令native2ascii命令进行转码:(native2ascii是jdk中的转码工具,在jdk的bin目录下)   2 ...

  3. Python--jsonpath

    JsonPath是一种信息抽取类库,是从JSON文档中抽取指定信息的工具,提供多种原因实现保本:JavaScript/Python/PHP和Java. 使用方法如: import jsonpathre ...

  4. MySQLdb和pymysql区别

    MySQLdb要快点,原因是这个是C写的,速度快 MySQLdb只支持Python2.x,还不支持3.x 可以用PyMySQL代替.安装方法:pip install PyMySQL 然后在需要的项目中 ...

  5. 【动态规划】Concerts

    Concerts 题目描述 John enjoys listening to several bands, which we shall denote using A through Z. He wa ...

  6. MySql数据库 优化

    MySQL数据库优化方案 Mysql的优化,大体可以分为三部分:索引的优化,sql慢查询的优化,表的优化. 开启慢查询日志,可以让MySQL记录下查询超过指定时间的语句,通过定位分析性能的瓶颈,才能更 ...

  7. php 环境搭建问题

    项目过程中需要用到 PHP环境 https://www.cnblogs.com/cyrfr/p/6483529.html APACHE无法启动:THE REQUEST OPERATION HAS FA ...

  8. JS基础_this

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. Android中BroadcastReceiver的使用

    1.Android中广播分为静态注册和动态注册 2.下面是一个简单静态注册的例子 创建一个继承BroadcastReceiver的子类 public class DeviceBootReceiver ...

  10. stm32 ds18b20 温度传感器

    相关文章:http://blog.csdn.net/zhangxuechao_/article/details/74991985 举例 void DS18B20_in() { GPIO_InitTyp ...