def echo(): """Use in a `with` block to draw some code on the app, then execute it. Example ------- >>> with st.echo(): >>> st.write('This code will be printed') """ code = empty() # noqa: F821 try: frame = _traceback.extract_stack()[-3] if _is_running_py3(): filename, start_line = frame.filename, frame.lineno else: filename, start_line = frame[:2] yield frame = _traceback.extract_stack()[-3] if _is_running_py3(): end_line = frame.lineno else: end_line = frame[1] lines_to_display = [] with _source_util.open_python_file(filename) as source_file: source_lines = source_file.readlines() lines_to_display.extend(source_lines[start_line:end_line]) initial_spaces = _SPACES_RE.match(lines_to_display[0]).end() for line in source_lines[end_line:]: indentation = _SPACES_RE.match(line).end() # The != 1 is because we want to allow '\n' between sections. if indentation != 1 and indentation < initial_spaces: break lines_to_display.append(line) lines_to_display = _textwrap.dedent("".join(lines_to_display)) code.code(lines_to_display, "python") except FileNotFoundError as err: # noqa: F821 code.warning("Unable to display code. %s" % err)
def echo(): """Use in a `with` block to draw some code on the report, then execute it. Example ------- >>> with st.echo(): >>> st.write('This code will be printed') """ code = empty() # noqa: F821 try: frame = _traceback.extract_stack()[-3] if _is_running_py3(): filename, start_line = frame.filename, frame.lineno else: filename, start_line = frame[:2] yield frame = _traceback.extract_stack()[-3] if _is_running_py3(): end_line = frame.lineno else: end_line = frame[1] lines_to_display = [] with open(filename) as source_file: source_lines = source_file.readlines() lines_to_display.extend(source_lines[start_line:end_line]) initial_spaces = _SPACES_RE.match(lines_to_display[0]).end() for line in source_lines[end_line:]: if _SPACES_RE.match(line).end() < initial_spaces: break lines_to_display.append(line) lines_to_display = _textwrap.dedent(''.join(lines_to_display)) code.code(lines_to_display, 'python') except FileNotFoundError as err: # noqa: F821 code.warning('Unable to display code. %s' % err)
"DataFrame", # pandas.core.frame.DataFrame "Index", # pandas.core.indexes.base.Index "Series", # pandas.core.series.Series "Styler", # pandas.io.formats.style.Styler "ndarray", # numpy.ndarray ) _HELP_TYPES = ( _types.BuiltinFunctionType, _types.BuiltinMethodType, _types.FunctionType, _types.MethodType, _types.ModuleType, ) if not _is_running_py3(): _HELP_TYPES = list(_HELP_TYPES) _HELP_TYPES.append(_types.ClassType) _HELP_TYPES.append(_types.InstanceType) _HELP_TYPES = tuple(_HELP_TYPES) def write(*args, **kwargs): """Write arguments to the app. This is the swiss-army knife of Streamlit commands. It does different things depending on what you throw at it. Unlike other Streamlit commands, write() has some unique properties: 1. You can pass in multiple arguments, all of which will be written.