Streamlit allows you to write Markdown within a Python file (.py):

import streamlit as st

st.title("Otto Group Product Classification Challenge πŸ›")

st.markdown("## 1. Problem Statement")
    "Given a [dataset]( with **93 features**, create a **predictive model** which is able to **distinguish between the main product categories**."

st.markdown("### 1.2 Evaluation")
    "The evaluation for the competition is **multi-class logarithm loss**. See [Kaggle: Evaluation.]("

I like that I can write Markdown, but the syntax is cumbersome. You have to wrap your text into st.markdown() for every line.

Let’s sprinkle in some magic! ✨

Streamlit Magic

Magic commands are a feature in Streamlit that allows you to write markdown and data to your app with very few keypresses.

Let’s see it in action:

# previous code
# imports, etc.

## 3. Prepare Data

Split the data into **training and test set**.


X = df.drop(["target"], axis=1)
y =

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

"Data shapes:"
"X_train:", X_train.shape
"X_test:", X_test.shape
"y_train:", y_train.shape
"y_test:", y_test.shape

Now you have a mixture between code and user-facing output in your Streamlit application:

Streamlit Magic Example
Streamlit Magic Example

Further Reading