rapidsai/cudf

[FEA] efficient way to truncate by month

Open

#18.650 aberto em 3 de mai. de 2025

Ver no GitHub
 (5 comments) (0 reactions) (1 assignee)C++ (735 forks)batch import
Pythonfeature requestgood first issuelibcudf

Métricas do repositório

Stars
 (6.000 stars)
Métricas de merge de PR
 (Mesclagem média 17d 21h) (230 fundiu PRs em 30d)

Description

Is there an efficient way to truncate a Series by month / quarter in cuDF?

https://docs.rapids.ai/api/cudf/latest/user_guide/api_docs/api/cudf.core.series.datetimeproperties.floor/ dt.floor doesn't support month / year / quarter

In pandas I can either, depending on the dtype backend:

  • drop to numpy and use astype('datetime64["3M"]'))
  • drop to PyArrow and use pc.floor_temporal

Any suggestion for cuDF?

Example: given

import cudf
from datetime import datetime

s = cudf.Series([datetime(2020, 2, 4)])
s.dt.truncate('3 months')  # Not valid syntax, I know :)

I'd like to end up with

'2020-01-01'

Guia do colaborador