@_with_element
def radio(self, element, label, options, index=0, format_func=str, key=None):
    'Display a radio button widget.\n\n        Parameters\n        ----------\n        label : str\n            A short label explaining to the user what this radio group is for.\n        options : list, tuple, numpy.ndarray, or pandas.Series\n            Labels for the radio options. This will be cast to str internally\n            by default.\n        index : int\n            The index of the preselected option on first render.\n        format_func : function\n            Function to modify the display of radio options. It receives\n            the raw option as an argument and should output the label to be\n            shown for that option. This has no impact on the return value of\n            the radio.\n        key : str\n            An optional string to use as the unique key for the widget.\n            If this is omitted, a key will be generated for the widget\n            based on its content. Multiple widgets of the same type may\n            not share the same key.\n\n        Returns\n        -------\n        any\n            The selected option.\n\n        Example\n        -------\n        >>> genre = st.radio(\n        ...     "What\'s your favorite movie genre",\n        ...     (\'Comedy\', \'Drama\', \'Documentary\'))\n        >>>\n        >>> if genre == \'Comedy\':\n        ...     st.write(\'You selected comedy.\')\n        ... else:\n        ...     st.write("You didn\'t select comedy.")\n\n        '
    if (not isinstance(index, int)):
        raise StreamlitAPIException(('Radio Value has invalid type: %s' % type(index).__name__))
    if ((len(options) > 0) and (not (0 <= index < len(options)))):
        raise StreamlitAPIException('Radio index must be between 0 and length of options')
    element.radio.label = label
    element.radio.default = index
    element.radio.options[:] = [str(format_func(option)) for option in options]
    ui_value = _get_widget_ui_value('radio', element, user_key=key)
    current_value = (ui_value if (ui_value is not None) else index)
    return (options[current_value] if ((len(options) > 0) and (options[current_value] is not None)) else NoValue)
Display a radio button widget.

Parameters
----------
label : str
    A short label explaining to the user what this radio group is for.
options : list, tuple, numpy.ndarray, or pandas.Series
    Labels for the radio options. This will be cast to str internally
    by default.
index : int
    The index of the preselected option on first render.
format_func : function
    Function to modify the display of radio options. It receives
    the raw option as an argument and should output the label to be
    shown for that option. This has no impact on the return value of
    the radio.
key : str
    An optional string to use as the unique key for the widget.
    If this is omitted, a key will be generated for the widget
    based on its content. Multiple widgets of the same type may
    not share the same key.

Returns
-------
any
    The selected option.

Example
-------
>>> genre = st.radio(
...     "What's your favorite movie genre",
...     ('Comedy', 'Drama', 'Documentary'))
>>>
>>> if genre == 'Comedy':
...     st.write('You selected comedy.')
... else:
...     st.write("You didn't select comedy.")
@_with_element
def radio(self, element, label, options, index=0, format_func=str, key=None):
    'Display a radio button widget.\n\n        Parameters\n        ----------\n        label : str\n            A short label explaining to the user what this radio group is for.\n        options : list, tuple, numpy.ndarray, or pandas.Series\n            Labels for the radio options. This will be cast to str internally\n            by default.\n        index : int\n            The index of the preselected option on first render.\n        format_func : function\n            Function to modify the display of radio options. It receives\n            the raw option as an argument and should output the label to be\n            shown for that option. This has no impact on the return value of\n            the radio.\n        key : str\n            An optional string to use as the unique key for the widget.\n            If this is omitted, a key will be generated for the widget\n            based on its content. Multiple widgets of the same type may\n            not share the same key.\n\n        Returns\n        -------\n        any\n            The selected option.\n\n        Example\n        -------\n        >>> genre = st.radio(\n        ...     "What\'s your favorite movie genre",\n        ...     (\'Comedy\', \'Drama\', \'Documentary\'))\n        >>>\n        >>> if genre == \'Comedy\':\n        ...     st.write(\'You selected comedy.\')\n        ... else:\n        ...     st.write("You didn\'t select comedy.")\n\n        '
    if (not isinstance(index, int)):
        raise StreamlitAPIException(('Radio Value has invalid type: %s' % type(index).__name__))
    if ((len(options) > 0) and (not (0 <= index < len(options)))):
        raise StreamlitAPIException('Radio index must be between 0 and length of options')
    element.radio.label = label
    element.radio.default = index
    element.radio.options[:] = [str(format_func(option)) for option in options]
    ui_value = _get_widget_ui_value('radio', element, user_key=key)
    current_value = (ui_value if (ui_value is not None) else index)
    return (options[current_value] if ((len(options) > 0) and (options[current_value] is not None)) else NoValue)