From 6e0819579710662620a231c129cd159821f21db4 Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Wed, 30 Oct 2024 07:36:10 -0400 Subject: [PATCH] docs(examples): add DayOfWeek method examples (#10394) --- ibis/expr/types/temporal.py | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/ibis/expr/types/temporal.py b/ibis/expr/types/temporal.py index 9a2c59b238a9..e39b1019a276 100644 --- a/ibis/expr/types/temporal.py +++ b/ibis/expr/types/temporal.py @@ -1251,6 +1251,39 @@ def index(self): ------- IntegerValue The index of the day of the week. + + Examples + -------- + >>> from datetime import date + >>> import ibis + >>> ibis.options.interactive = True + >>> t = ibis.memtable( + ... { + ... "date_col": [ + ... date(2024, 10, 27), + ... date(2024, 10, 28), + ... date(2024, 10, 29), + ... date(2024, 10, 30), + ... date(2024, 10, 31), + ... date(2024, 11, 1), + ... date(2024, 11, 2), + ... ] + ... }, + ... ) + >>> t.date_col.day_of_week.index() + ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓ + ┃ DayOfWeekIndex(date_col) ┃ + ┡━━━━━━━━━━━━━━━━━━━━━━━━━━┩ + │ int16 │ + ├──────────────────────────┤ + │ 6 │ + │ 0 │ + │ 1 │ + │ 2 │ + │ 3 │ + │ 4 │ + │ 5 │ + └──────────────────────────┘ """ return ops.DayOfWeekIndex(self._expr).to_expr() @@ -1261,5 +1294,38 @@ def full_name(self): ------- StringValue The name of the day of the week + + Examples + -------- + >>> from datetime import date + >>> import ibis + >>> ibis.options.interactive = True + >>> t = ibis.memtable( + ... { + ... "date_col": [ + ... date(2024, 10, 27), + ... date(2024, 10, 28), + ... date(2024, 10, 29), + ... date(2024, 10, 30), + ... date(2024, 10, 31), + ... date(2024, 11, 1), + ... date(2024, 11, 2), + ... ] + ... }, + ... ) + >>> t.date_col.day_of_week.full_name() + ┏━━━━━━━━━━━━━━━━━━━━━━━━━┓ + ┃ DayOfWeekName(date_col) ┃ + ┡━━━━━━━━━━━━━━━━━━━━━━━━━┩ + │ string │ + ├─────────────────────────┤ + │ Sunday │ + │ Monday │ + │ Tuesday │ + │ Wednesday │ + │ Thursday │ + │ Friday │ + │ Saturday │ + └─────────────────────────┘ """ return ops.DayOfWeekName(self._expr).to_expr()