Floor or ceiling of a pandas series in python?

前端 未结 4 1998
轻奢々
轻奢々 2020-12-03 00:39

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?

4条回答
  •  情书的邮戳
    2020-12-03 01:07

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

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

提交回复
热议问题