Giter VIP home page Giter VIP logo

streamlit-magic's Introduction

Streamlit-Magic

Magic command is a feature in Streamlit that allows you to write almost anything (markdown, numbers, DataFrames, charts) without having to type an explicit command at all. Just put the thing you want to show on its own line of code, and it will appear in your app.

In a nutshell, the magical thing about magic commands is that there is no commands at all! Just by using variables or literal values and it is magically recognized by Streamlit and displayed in the app.

Also, magic is smart enough to ignore docstrings. That is, it ignores the strings at the top of files and functions.

If you prefer to call Streamlit commands more explicitly, you can always turn magic off in your ~/.streamlit/config.toml with the following setting:

[runner]
magicEnabled = false

Demo app

Streamlit App

Code

Here's how to use st.write:

import streamlit as st

# 1. Display text
'Hello world'

# 2. Display a title and some text to the app:
'''
# This is the document title
This is some _markdown_.
'''

# 3. Display the dataframe
import pandas as pd
df = pd.DataFrame({'col1': [1,2,3], 'col2': [4,5,6]})
df 

# 4. Display the string 'x' and then the value of x
x = 10
'x', x

# 5. Display Matplotlib chart
import matplotlib.pyplot as plt
import numpy as np

y = np.random.normal(0, 1, size=1000)
fig, ax = plt.subplots()
ax.hist(y, bins=20)

fig

streamlit-magic's People

Contributors

dataprofessor avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.