Skip to content

Commit

Permalink
fix: Make day_of_week and day_of_year components be recognized by xar…
Browse files Browse the repository at this point in the history
…ray. Refs #37 🔧
  • Loading branch information
luukvdmeer committed Jan 17, 2024
1 parent 0e51d98 commit 4676dd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions semantique/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class time():
DAY = "day"
""":obj:`str` : Component storing the day number of a timestamp."""

DAY_OF_WEEK = "day_of_week"
DAY_OF_WEEK = "dayofweek"
""":obj:`str` : Component storing the day of the week of a timestamp.
The first day of the week is considered Monday, with an index of 0.
"""

DAY_OF_YEAR = "day_of_year"
DAY_OF_YEAR = "dayofyear"
""":obj:`str` : Component storing the day of the year of a timestamp."""

HOUR = "hour"
Expand Down
8 changes: 8 additions & 0 deletions semantique/processor/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ def _extract_time(obj, component = None):
try:
out = out[component]
except KeyError:
aliases = {
"day_of_week": "dayofweek",
"day_of_year": "dayofyear"
}
try:
component = aliases[component]
except KeyError:
pass
try:
out = getattr(out.dt, component)
except AttributeError:
Expand Down

0 comments on commit 4676dd5

Please sign in to comment.