Skip to content

Instantly share code, notes, and snippets.

@karanjagota
Last active April 12, 2021 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karanjagota/cfd76e13664cf120094e68f151773502 to your computer and use it in GitHub Desktop.
Save karanjagota/cfd76e13664cf120094e68f151773502 to your computer and use it in GitHub Desktop.
# Import statements
import streamlit as st
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from PIL import Image
#Title and Subheader
st.title("Life Expectancy By Country")
st.write("Life Expectancy Data of India and USA from the year 1960 till 2016.")
# Multicolumn Support (add relative path to the image)
col1, col2 = st.beta_columns(2)
IN_flag = Image.open(r"xxxxxxxxxxxxxxx")
col1.header("INDIA")
col1.image(IN_flag, use_column_width=True)
US_flag = Image.open(r"xxxxxxxxxxxxxxxx")
col2.header("USA")
col2.image(US_flag, use_column_width=True)
# reading a csv and displaying the first six rows on the screen.
df = pd.read_csv('lf.csv')
st.write(df.head())
# Display full data base on checkbox.
if st.checkbox('show full data'):
df
# Display Code
st.write('Displaying Code in Streamlit app')
with st.echo():
# square function
def square(x):
print(x*x)
# cube function
def cube(x):
print(x*x*x)
square(5) #output 25
cube(5) # output 125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment