cudf icon indicating copy to clipboard operation
cudf copied to clipboard

[FEA] dt.total_seconds

Open MarcoGorelli opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

I wish I could use cuDF to do .dt.total_seconds on a timedelta column

Describe the solution you'd like

.dt.total_seconds

Describe alternatives you've considered

Additional context

We're (for now) xfailing tests in Narwhals https://github.com/narwhals-dev/narwhals/pull/951

MarcoGorelli avatar Sep 12 '24 08:09 MarcoGorelli

Thanks for the report!

Although this could be easily implemented by summing the timedelta components, I think there was a desire to implement a dedicated libcudf kernel for total_seconds to avoid the n kernel launches to sum each individual component (IIRC cc @bdice you may have been apart of that passing discussion somewhere)

mroeschke avatar Sep 16 '24 20:09 mroeschke

I think this might be simple, and may not require summing components. I think we can do a conversion/cast to duration_s and then cast that as a float type to match pandas.

edit: we may need to cast to the smallest duration type (nanos?) and then divide by the appropriate scale factor (1e9), in order to retain subsecond information.

bdice avatar Oct 16 '24 21:10 bdice