-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Description
Describe the enhancement requested
There are currently pyarrow functions converting a pa.date32() to its year / month / day. But there isn't a function that does the invert, accepting a year, a month and a day and returning a pa.date32.
The current work around involve either using python datetime.date (but it is slow and the range is limited). Alternatively one can build a date string from the component and parse it. But it's far from ideal
import pyarrow as pa
import pyarrow.compute as pc
table = pa.table({"year": [2024, 2025], "month": [3, 7], "day": [10, 4]})
date_str = pc.binary_join_element_wise(
pc.cast(table["year"], pa.string()),
pc.utf8_lpad(pc.cast(table["month"], pa.string()), 2, "0"),
pc.utf8_lpad(pc.cast(table["day"], pa.string()), 2, "0"),
"-"
)
dates = pc.cast(date_str, pa.date32())
Component(s)
Python
Reactions are currently unavailable