dropna(subset)_python中的head函数

dropna(subset)_python中的head函数”””ReturnobjectwithlabelsongivenaxisomittedwherealternatelyanyorallofthedataaremissingParameters———-axis:{0or‘index‘,1or‘columns‘},ortuple/listthereofPasstupleorlist…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

“””

Return object with labels on given axis omitted where alternately any

or all of the data are missing

Parameters

———-

axis : {0 or ‘index‘, 1 or ‘columns‘}, or tuple/list thereof

Pass tuple or list to drop on multiple axes

how : {‘any‘, ‘all‘}

* any : if any NA values are present, drop that label

* all : if all values are NA, drop that label

thresh : int, default None

int value : require that many non-NA values

subset : array-like

Labels along other axis to consider, e.g. if you are dropping rows

these would be a list of columns to include

inplace : boolean, default False

If True, do operation inplace and return None.

Returns

——-

dropped : DataFrame

Examples

——–

>>> df = pd.DataFrame([[np.nan, 2, np.nan, 0], [3, 4, np.nan, 1],

… [np.nan, np.nan, np.nan, 5]],

… columns=list(‘ABCD‘))

>>> df

A B C D

0 NaN 2.0 NaN 0

1 3.0 4.0 NaN 1

2 NaN NaN NaN 5

Drop the columns where all elements are nan:

>>> df.dropna(axis=1, how=‘all‘)

A B D

0 NaN 2.0 0

1 3.0 4.0 1

2 NaN NaN 5

Drop the columns where any of the elements is nan

>>> df.dropna(axis=1, how=‘any‘)

D

0 0

1 1

2 5

Drop the rows where all of the elements are nan

(there is no row to drop, so df stays the same):

>>> df.dropna(axis=0, how=‘all‘)

A B C D

0 NaN 2.0 NaN 0

1 3.0 4.0 NaN 1

2 NaN NaN NaN 5

Keep only the rows with at least 2 non-na values:

>>> df.dropna(thresh=2)

A B C D

0 NaN 2.0 NaN 0

1 3.0 4.0 NaN 1

“””

原文:https://www.cnblogs.com/YingxuanZHANG/p/8807395.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/192239.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • C#中遍历ArrayList的三种方法(转)

    C#中遍历ArrayList的三种方法(转)usingSystem;usingSystem.Collections;usingSystem.Linq;usingSystem.Text;namespaceArrayListDemo{classProgram{staticvoidMain(string[]args){…

    2022年7月22日
    8
  • java取整函数

    向上取整Math.ceil()向上取整:比自己大的最小整数ceil是天花板的意思,表示向上取整,用数学符号⌈⌉表示Math.ceil(6.1)=7.0Math.ceil(6.9)=7.0向下取整Math.floor()向下取整:比自己小的最大整数floor是地板的意思,表示向下取整,用数学符号⌊⌋表示Math.floor(9.1)=9.0Math.floor(9.9)=10.0Math.round()四舍五入后取整,其算法为Math.round(x+0

    2022年4月8日
    113
  • 使用递归实现买汽水(华为面试题)

    今天老范问了我一个问题问题:一个人买汽水,一块钱一瓶汽水,三个瓶盖可以换一瓶汽水,两个空瓶可以换一瓶汽水问20块钱可以买多少汽水?注意:使用递归这一题乍一看,哎哟,这么简单,能买几瓶?恩。。五瓶!为啥啊?多了我喝不完啊!老范说,喝不完关你屁事,又不是给你喝哦哦哦,那没事儿了,我想想。在知道自己的人生安全得到了保障之后,我冷静下来仔细思考了如何用递归实现这个问题

    2022年4月9日
    56
  • DNS多点部署IP Anycast+BGP实战分析

    DNS多点部署IP Anycast+BGP实战分析DNS领域的多点部署大多采用IPAnycast+BGP方式,采用这种方式不需要额外采购设备,部署灵活多样。但像其他所有技术一样,IPAnycast+BGP技术只有在适当的领域和范围内才能发挥它的最大优势。Internet不断发展,上网人群数量增加,多数网站或DNS等服务在使用单节点提供服务的情况下,无论服务器性能还是接入带宽都不足以承载大量的用户服务请求;而在国内运营商网络之间访问缓慢的

    2022年5月23日
    82
  • nginx配置访问本地静态资源

    nginx配置访问本地静态资源nginx作为一款高性能的服务器,用途很多,除了可以做后端服务器的代理,负载均衡之外你,还有一个用途就是做静态资源的缓存服务器,比如在前后端分离的项目中,为了加速前端页面的响应速度,我们可以将前端的相关资源,例如html,js,css或者图片等放到nginx指定的目录下,访问的时候只需要通过IP加路径就可以实现高效快速的访问,下面说说如何在windows下使用nginx作为静态资源服务器,1、……

    2022年7月14日
    159
  • jQuery+PHP+Mysql在线拍照和在线浏览照片

    jQuery+PHP+Mysql在线拍照和在线浏览照片

    2021年11月5日
    59

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号