您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – Pandas读取sql整数变为浮点数

5b51 2022/1/14 8:23:27 python 字数 1650 阅读 576 来源 www.jb51.cc/python

我遇到了一个问题,当我使用pandas读取Mysql表时,一些列(参见’to_nlc’)曾经是整数变成了一个浮点数(之后自动添加.0). 任何人都可以搞清楚吗?或者一些猜测?非常感谢! 问题是您的数据包含NaN值,因此int会自动转换为float. 我想你可以查看NA type promotions: When introducing NAs into an existing Series or

概述


我想你可以查看NA type promotions

When introducing NAs into an existing Series or DataFrame via reindex or some other means,boolean and integer types will be promoted to a different dtype in order to store the NAs. These are summarized by this table:

Typeclass   Promotion dtype for storing NAs
floating    no change
object      no change
integer     cast to float64
boolean     cast to object

While this may seem like a heavy Trade-off,in practice I have found very few cases where this is an issue in practice. Some explanation for the motivation here in the next section.

总结

以上是编程之家为你收集整理的python – Pandas读取sql整数变为浮点数全部内容,希望文章能够帮你解决python – Pandas读取sql整数变为浮点数所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶