Dates¶
Single date¶
- class marimo.ui.date(start: dt.date | str | None = None, stop: dt.date | str | None = None, value: dt.date | str | None = None, *, label: str = '', on_change: Callable[[dt.date], None] | None = None, full_width: bool = False)¶
A date picker with an optional start and stop date.
Example.
# initialize the date picker at a given date date = mo.ui.date(value="2022-01-01")
# when value is omitted, date picker initializes with today's date date = mo.ui.date()
# create a date picker with bounds date = mo.ui.date( value="2022-06-01", start="2022-01-01", stop="2022-12-31", )
Or from a dataframe series:
date = mo.ui.date.from_series(df["column_name"])
Attributes.
value: a str (YYYY-MM-DD) ordatetime.dateobject of the chosen datestart: the start datestop: the stop date
Initialization Args.
start: minimum date selectable; if None, defaults to 01-01-0001stop: maximum date selectable; if None, defaults to 12-31-9999value: default dateif
NoneandstartandstopareNone, defaults to the current day;else if
Noneandstartis notNone, defaults tostart;else if
Noneandstopis notNone, defaults tostop
label: markdown label for the elementon_change: optional callback to run when this element’s value changesfull_width: whether the input should take up the full width of its container
Public methods
from_series(series, **kwargs)Create a date picker from a dataframe series.
Inherited from
UIElementform([label, bordered, loading, ...])Create a submittable form out of this
UIElement.send_message(message, buffers)Send a message to the element rendered on the frontend from the backend.
Inherited from
Htmlbatch(**elements)Convert an HTML object with templated text into a UI element.
center()Center an item.
right()Right-justify.
left()Left-justify.
callout([kind])Create a callout containing this HTML element.
style([style])Wrap an object in a styled container.
Public Data Attributes:
DATE_FORMATstartstopInherited from
UIElementvalueThe element’s current value.
Inherited from
HtmltextA string of HTML representing this element.
Date and time¶
- class marimo.ui.datetime(start: dt.datetime | str | None = None, stop: dt.datetime | str | None = None, value: dt.datetime | str | None = None, *, label: str | None = None, on_change: Callable[[dt.datetime | None], None] | None = None, full_width: bool = False)¶
A datetime picker over an interval.
Example.
datetime_picker = mo.ui.datetime( start=dt.datetime(2023, 1, 1), stop=dt.datetime(2023, 12, 31, 23, 59, 59), )
Or from a dataframe series:
datetime_picker = mo.ui.datetime.from_series(df["datetime_column"])
Attributes.
value: the selected datetime, possiblyNonestart: the minimum selectable datetimestop: the maximum selectable datetime
Initialization Args.
start: the minimum selectable datetime (default: minimum datetime)stop: the maximum selectable datetime (default: maximum datetime)value: default valuelabel: markdown label for the elementon_change: optional callback to run when this element’s value changesfull_width: whether the input should take up the full width of its container
Public methods
from_series(series, **kwargs)Create a datetime picker from a dataframe series.
Inherited from
UIElementform([label, bordered, loading, ...])Create a submittable form out of this
UIElement.send_message(message, buffers)Send a message to the element rendered on the frontend from the backend.
Inherited from
Htmlbatch(**elements)Convert an HTML object with templated text into a UI element.
center()Center an item.
right()Right-justify.
left()Left-justify.
callout([kind])Create a callout containing this HTML element.
style([style])Wrap an object in a styled container.
Public Data Attributes:
DATETIME_FORMATstartstopInherited from
UIElementvalueThe element’s current value.
Inherited from
HtmltextA string of HTML representing this element.
Date range¶
- class marimo.ui.date_range(start: dt.date | str | None = None, stop: dt.date | str | None = None, value: Tuple[dt.date, dt.date] | Tuple[str, str] | None = None, *, label: str | None = None, on_change: Callable[[Tuple[dt.date, dt.date]], None] | None = None, full_width: bool = False)¶
A date range picker over an interval.
Example.
date_range = mo.ui.date_range( start=dt.date(2023, 1, 1), stop=dt.date(2023, 12, 31) )
Or from a dataframe series:
date_range = mo.ui.date_range.from_series(df["date_column"])
Attributes.
value: a tuple of two dates representing the selected rangestart: the minimum selectable datestop: the maximum selectable date
Initialization Args.
start: the minimum selectable date (default: minimum date)stop: the maximum selectable date (default: maximum date)value: default value (tuple of two dates)label: markdown label for the elementon_change: optional callback to run when this element’s value changesfull_width: whether the input should take up the full width of its container
Public methods
from_series(series, **kwargs)Create a date range picker from a dataframe series.
Inherited from
UIElementform([label, bordered, loading, ...])Create a submittable form out of this
UIElement.send_message(message, buffers)Send a message to the element rendered on the frontend from the backend.
Inherited from
Htmlbatch(**elements)Convert an HTML object with templated text into a UI element.
center()Center an item.
right()Right-justify.
left()Left-justify.
callout([kind])Create a callout containing this HTML element.
style([style])Wrap an object in a styled container.
Public Data Attributes:
DATEFORMATstartstopInherited from
UIElementvalueThe element’s current value.
Inherited from
HtmltextA string of HTML representing this element.
- static from_series(series: Any, **kwargs: Any) date_range¶
Create a date range picker from a dataframe series.