python中的 pandas 系列的地板或天花板? [英] Floor or ceiling of a pandas series in python?

查看:108
本文介绍了python中的 pandas 系列的地板或天花板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个熊猫系列series.如果我想获取按元素划分的地板或天花板,是否有内置方法,还是必须编写函数并使用apply?我问,因为数据很大,所以我很欣赏效率.同样,关于熊猫套餐,也没有问过这个问题.

I have a pandas series series. If I want to get the element-wise floor or ceiling, is there a built in method or do I have to write the function and use apply? I ask because the data is big so I appreciate efficiency. Also this question has not been asked with respect to the Pandas package.

推荐答案

您可以使用NumPy的内置方法来执行此操作:np.ceil(series)np.floor(series).

You can use NumPy's built in methods to do this: np.ceil(series) or np.floor(series).

两者都返回Series对象(而不是数组),因此保留了索引信息.

Both return a Series object (not an array) so the index information is preserved.

这篇关于python中的 pandas 系列的地板或天花板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆