FutureWarning: The default value of numeric_only in DataFrameGroupBy.mean is deprecated解决方法

这篇具有很好参考价值的文章主要介绍了FutureWarning: The default value of numeric_only in DataFrameGroupBy.mean is deprecated解决方法。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、运行如下代码

import pandas as pd
import numpy as np
df = pd.DataFrame({'颜色': ['蓝色', '灰色', '蓝色', '灰色', '黑色'], '商品': ['钢笔', '钢笔', '铅笔', '铅笔', '文具盒'],'售价':[2.5, 2.3, 1.5, 1.3, 5.2],'会员价':[2.2, 2, 1.3, 1.2, 5.0]})
df
--------------------------------------------------------------------------------
df.groupby(['商品']).mean()

二、警告如下

FutureWarning: The default value of numeric_only in DataFrameGroupBy.mean is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function.

翻译如下:

FutureWarning:DataFrameGroupBy.mean 中的默认值 numeric_only 已弃用。在将来的版本中,numeric_only将默认为 False。指定numeric_only或仅选择对函数有效的列

futurewarning: the default value of numeric_only in dataframegroupby.sum is,问题,python,开发语言,pandas,数据分析,数据挖掘

三、解决方法

如翻译所述,需指定numeric_only或仅选择对函数有效的列

指定numeric_only=False,结果如下,未解决

futurewarning: the default value of numeric_only in dataframegroupby.sum is,问题,python,开发语言,pandas,数据分析,数据挖掘解决方法一:指定numeric_only=True,警告消失,结果如下

futurewarning: the default value of numeric_only in dataframegroupby.sum is,问题,python,开发语言,pandas,数据分析,数据挖掘

解决方法二:仅选择对函数有效的列,警告消失,如下

futurewarning: the default value of numeric_only in dataframegroupby.sum is,问题,python,开发语言,pandas,数据分析,数据挖掘

futurewarning: the default value of numeric_only in dataframegroupby.sum is,问题,python,开发语言,pandas,数据分析,数据挖掘

学习导航:http://xqnav.top/文章来源地址https://www.toymoban.com/news/detail-540798.html

到了这里,关于FutureWarning: The default value of numeric_only in DataFrameGroupBy.mean is deprecated解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Failed to calculate the value of task ‘:unityLibrary:compileDebugJavaWithJavac‘

    在打包时出现了如下问题: Failed to calculate the value of task \\\':unityLibrary:compileDebugJavaWithJavac\\\' property \\\'options.generatedSourceOutputDirectory\\\' 这个是由于 Gradle 版本导致的,Gradle 7.x 及以上版本进行了更新,将 Gradle 版本下调至 6.x 版本即可解决。

    2024年02月11日
    浏览(46)
  • vue3 + naive ui + Tabs 报错 ‘Slot “default“ invoked outside of the render function‘

    警告的异常信息: 解决方法: 如下给Tabs组件加一个defaultValue的默认值即可 参考:https://github.com/tusen-ai/naive-ui/issues/3134

    2024年01月21日
    浏览(31)
  • Pioneer | X METAVERSE PRO Explores the New Value of “Mining + Finance“

    “The mining boom driven by Bitcoin has created many wealth myths: miners can earn 50 BTC every 10 minutes at that time. If you successfully get a Bitcoin block and hold it since 2009, you will have BTC worth $827,930 in your wallet by 2022. “ Cryptocurrency mining is an investment track with high popularity and high returns in the market. Especially in t

    2024年01月16日
    浏览(52)
  • this version of the Java Runtime only recognizes class file versions up to 52.0

    博客上很多博主说这个是jdk版本的问题,我所有地方都设置的是jdk1.8,但还是报错 Caused by: java.lang.UnsupportedClassVersionError: org/springframework/cloud/bootstrap/RefreshBootstrapRegistryInitializer has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only re

    2024年02月11日
    浏览(98)
  • Gradle打包报错:Failed to calculate the value of task ‘:unityLibrary:compileReleaseJavaWithJavac‘

    Unity项目使用Gradle打包时报如下错误: Failed to calculate the value of task \\\':unityLibrary:compileReleaseJavaWithJavac\\\' property \\\'options.generatedSourceOutputDirectory\\\'. Unity版本:2020.3.17f1; Gradle版本:7.6; 来自Unity官方的解决方案:更换Gradle版本为6.7或者6.8即可  原文链接:Troubleshooting Android integration

    2024年02月11日
    浏览(33)
  • 解决PyTorch DDP: Finding the cause of “Expected to mark a variable ready only once“

    早上做消融实验的时候需要复现俩月前的实验结果,但是莫名其妙同样的代码和环境却跑不通了,会在loss.backward()的时候报如下错误: RuntimeError: Expected to mark a variable ready only once. This error is caused by one of the following reasons: 1) Use of a module parameter outside the ``forward`` function. Please

    2024年02月07日
    浏览(38)
  • 彻底解决this version of the Java Runtime only recognizes class file versions up to 52.0

    这个错误的意思是当时开发程序的人使用的JDK的版本要比你现在运行的环境上的JDK版本高。比如他是使用JDK11开发的,然后把程序打包好,你下载了他的jar包到本地运行,然后报错,可能你本地的JDK版本是低于11的,所以报错。 安装JDK21就行。继续看文章下面的对应关系,就知

    2024年02月02日
    浏览(42)
  • 【已解决】this version of the Java Runtime only recognizes class file versions up to 52.0

    在把springboot项目打包了jar之后,准备本地运行一下 然后报错: 编译版本和运行版本不一致,可能是编译版本高于运行版本导致的 修改pom.xml, 将此版本改为 java -version 版本 为 spring-boot-maven-plugin 增加 parent的版本号 如果没指定spring-boot-maven-plugin 的版本,就会拿取最新的版本打

    2023年04月16日
    浏览(95)
  • redis报错WRONGTYPE Operation against a key holding the wrong kind of value

    在redis中我们一般存储string、list、hash类型的值,对应的方法分别为 db.StringGet(“key”)、db.ListRange、db.HashGetAll 如果取list类型值时使用了string的方法就会报WRONGTYPE Operation against a key holding the wrong kind of value错误。 redis-cli命令窗口 C#实现

    2024年02月11日
    浏览(31)
  • idea 报错Java Runtime (class file version 61.0), this version of the Java Runtime only ...55.0

    RootLogLevelConfigurator has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 55对应jdk11,61对应jdk17. 查看自己pom文件中java的版本,将版本改为11 setting中版本改为11 project structure中版本改为11 pom中指定spring

    2024年02月08日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包