Skip to content

Commit a43ad4a

Browse files
committed
add dt.floor
1 parent d5950af commit a43ad4a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

spec/API_specification/dataframe_api/column_object.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,3 +901,38 @@ def iso_weekday(self) -> Self:
901901
"""
902902
...
903903

904+
def floor(self, frequency: str) -> Column:
905+
"""
906+
Return floor of each element according to the specified frequency.
907+
908+
Flooring is done according to local time. For example,
909+
for a ``Datetime('us', 'Europe/London')`` column,
910+
``"2020-10-25T00:30:00 BST"`` floored by ``"1day"`` gives
911+
``"2020-10-25T00:00:00 BST"``.
912+
Behaviours in the face of ambiguous and non-existent times are
913+
currently unspecified and may vary across implementations.
914+
915+
Flooring by non-fixed durations (e.g. calendar month) are not supported.
916+
Note that flooring by ``timedelta(days=1)`` is equivalent to flooring
917+
by ``timedelta(hours=24)``.
918+
919+
Parameters
920+
----------
921+
freq : str
922+
Frequency to floor by. Can be constructed using the following string
923+
language:
924+
925+
- "1day"
926+
- "1hour"
927+
- "1minute"
928+
- "1second"
929+
- "1millisecond"
930+
- "1microsecond"
931+
932+
Examples
933+
--------
934+
Roll each datetime back to the beginning of the day:
935+
936+
>>> column: Column
937+
>>> column.dt.floor("1day")
938+
"""

0 commit comments

Comments
 (0)