tidypolars.lubridate
¶
Module Contents¶
Functions¶
|
Convert a string to a Date |
|
Convert a string to a Datetime |
|
Extract the hour from a datetime |
|
Extract the month day from a date from 1 to 31. |
|
Create a date object |
|
Create a datetime object |
|
Extract the minute from a datetime |
|
Extract the month from a date |
|
Extract the quarter from a date |
|
Round the datetime |
|
Extract the second from a datetime |
|
Extract the weekday from a date from sunday = 1 to saturday = 7. |
|
Extract the week from a date |
|
Extract the year day from a date from 1 to 366. |
|
Extract the year from a date |
- as_date(x, fmt=None)[source]¶
Convert a string to a Date
- Parameters:
x (Expr, Series) – Column to operate on
fmt (str) – “yyyy-mm-dd”
Examples
>>> df = tp.Tibble(x = ['2021-01-01', '2021-10-01']) >>> df.mutate(date_x = tp.as_date(col('x')))
- as_datetime(x, fmt=None)[source]¶
Convert a string to a Datetime
- Parameters:
x (Expr, Series) – Column to operate on
fmt (str) – “yyyy-mm-dd”
Examples
>>> df = tp.Tibble(x = ['2021-01-01', '2021-10-01']) >>> df.mutate(date_x = tp.as_datetime(col('x')))
- hour(x)[source]¶
Extract the hour from a datetime
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(hour = tp.as_hour(col('x')))
- mday(x)[source]¶
Extract the month day from a date from 1 to 31.
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(monthday = tp.mday(col('x')))
- make_date(year=1970, month=1, day=1)[source]¶
Create a date object
- Parameters:
year (Expr, str, int) – Column or literal
month (Expr, str, int) – Column or literal
day (Expr, str, int) – Column or literal
Examples
>>> df.mutate(date = tp.make_date(2000, 1, 1))
- make_datetime(year=1970, month=1, day=1, hour=0, minute=0, second=0)[source]¶
Create a datetime object
- Parameters:
year (Expr, str, int) – Column or literal
month (Expr, str, int) – Column or literal
day (Expr, str, int) – Column or literal
hour (Expr, str, int) – Column or literal
minute (Expr, str, int) – Column or literal
second (Expr, str, int) – Column or literal
Examples
>>> df.mutate(date = tp.make_datetime(2000, 1, 1))
- minute(x)[source]¶
Extract the minute from a datetime
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(hour = tp.minute(col('x')))
- month(x)[source]¶
Extract the month from a date
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(year = tp.month(col('x')))
- quarter(x)[source]¶
Extract the quarter from a date
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(quarter = tp.quarter(col('x')))
- dt_round(x, rule, n)[source]¶
Round the datetime
- Parameters:
x (Expr, Series) – Column to operate on
rule (str) –
Units of the downscaling operation. Any of:
”month”
”week”
”day”
”hour”
”minute”
”second”
n (int) – Number of units (e.g. 5 “day”, 15 “minute”.
Examples
>>> df.mutate(monthday = tp.mday(col('x')))
- second(x)[source]¶
Extract the second from a datetime
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(hour = tp.minute(col('x')))
- wday(x)[source]¶
Extract the weekday from a date from sunday = 1 to saturday = 7.
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(weekday = tp.wday(col('x')))
- week(x)[source]¶
Extract the week from a date
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(week = tp.week(col('x')))