@@ -788,6 +788,62 @@ def tail(self, n: int) -> Self:
788788 def round (self , decimals : int ) -> Self :
789789 return self ._with_native (self .native .round (decimals = decimals ))
790790
791+ def floor (self ) -> Self :
792+ native = self .native
793+ native_cls = type (native )
794+ implementation = self ._implementation
795+ if get_dtype_backend (native .dtype , implementation = implementation ) == "pyarrow" :
796+ import pyarrow .compute as pc
797+
798+ from narwhals ._arrow .utils import native_to_narwhals_dtype
799+
800+ ca = native .array ._pa_array
801+ result_arr = cast ("ChunkedArrayAny" , pc .floor (ca ))
802+ nw_dtype = native_to_narwhals_dtype (result_arr .type , self ._version )
803+ out_dtype = narwhals_to_native_dtype (
804+ nw_dtype , "pyarrow" , self ._implementation , self ._version
805+ )
806+ result_native = native_cls (
807+ result_arr , dtype = out_dtype , index = native .index , name = native .name
808+ )
809+ else :
810+ array_funcs = self ._array_funcs
811+ result_arr = array_funcs .floor (self .native )
812+ result_native = (
813+ native_cls (result_arr , index = native .index , name = native .name )
814+ if implementation .is_cudf ()
815+ else result_arr
816+ )
817+ return self ._with_native (result_native )
818+
819+ def ceil (self ) -> Self :
820+ native = self .native
821+ native_cls = type (native )
822+ implementation = self ._implementation
823+ if get_dtype_backend (native .dtype , implementation = implementation ) == "pyarrow" :
824+ import pyarrow .compute as pc
825+
826+ from narwhals ._arrow .utils import native_to_narwhals_dtype
827+
828+ ca = native .array ._pa_array
829+ result_arr = cast ("ChunkedArrayAny" , pc .ceil (ca ))
830+ nw_dtype = native_to_narwhals_dtype (result_arr .type , self ._version )
831+ out_dtype = narwhals_to_native_dtype (
832+ nw_dtype , "pyarrow" , self ._implementation , self ._version
833+ )
834+ result_native = native_cls (
835+ result_arr , dtype = out_dtype , index = native .index , name = native .name
836+ )
837+ else :
838+ array_funcs = self ._array_funcs
839+ result_arr = array_funcs .ceil (self .native )
840+ result_native = (
841+ native_cls (result_arr , index = native .index , name = native .name )
842+ if implementation .is_cudf ()
843+ else result_arr
844+ )
845+ return self ._with_native (result_native )
846+
791847 def to_dummies (self , * , separator : str , drop_first : bool ) -> PandasLikeDataFrame :
792848 from narwhals ._pandas_like .dataframe import PandasLikeDataFrame
793849
0 commit comments