pythonpandasseriesfloorceil

Floor or ceiling of a pandas series in python?


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.


Solution

  • 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.