[英]How to change the pandas dataframe 'unnamed 0' column datatype from int64 to string or object
I am working on small project where i am trying to send the pandas dataframe to mysql database.我正在做一个小项目,我试图将 pandas dataframe 发送到 mysql 数据库。
My Dataframe contain default unnamed column which I want to send on mysql server.我的 Dataframe 包含我想在 mysql 服务器上发送的默认未命名列。 My sql schema contain id column with varchar(255) datatype.
我的 sql 架构包含数据类型为 varchar(255) 的 id 列。
create table users_sample(
id varchar(255) NOT NULL PRIMARY KEY,
#other_columns)
when i try to send the code on server i am getting the below errror当我尝试在服务器上发送代码时出现以下错误
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1364, "Field 'id' doesn't have a default value")
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1364, “字段‘id’没有默认值”)
When i serach for the solution it was suggesting that to change the datatype from varchar to int and put auto_increment constraint.当我搜索解决方案时,它建议将数据类型从 varchar 更改为 int 并放置 auto_increment 约束。
plz provide the solution.请提供解决方案。
Thanks in advance.提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.