Skip to content

Instantly share code, notes, and snippets.

@alanjones2
alanjones2 / app.py
Last active May 30, 2024 19:59
Web visualization using Flask and Plotly
from flask import Flask, render_template
import pandas as pd
import json
import plotly
import plotly.express as px
app = Flask(__name__)
@app.route('/')
def index():
@alanjones2
alanjones2 / 07-06-21-sentiment-test.py
Last active June 7, 2021 12:18
Sentiment analysis test
# Test the accuracy of TextBlob and VADER with tweet data from Sentiment140
# This code is for educational and demonstration purposes only
from textblob import TextBlob
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import pandas as pd
def rounder(num):
return round(num)
@alanjones2
alanjones2 / voilaweather.tx
Created February 20, 2022 21:10
voila weather
import pandas as pd
import ipywidgets as widgets
weather=pd.read_csv('heathrowDataFiltered.csv')
def fmax(year):
yticks = [0,5,10,15,20,25,30]
label="Degrees Celsius"
f(year, 'Tmax','line', yticks, label)
@alanjones2
alanjones2 / mercuryweather1.txt
Created February 20, 2022 21:12
mercury weather 2
import numpy as np
import pandas as pd
weather=pd.read_csv('heathrowDataFiltered.csv')
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, ncols=2,figsize=(10,7))
def plotchart(y,yticks,label,ax, kind):
@alanjones2
alanjones2 / 02-06-22-stmulitpage-mp4.py
Created June 2, 2022 10:39
02-06-22-stmulitpage-mp4.py
message = """
__Select an application from the list below__
"""
import json
import streamlit as st
import importlib
import stlib # default library name for apps
from stlib import libContents
message = """
__Select an application from the list below__
"""
import streamlit as st
st.set_page_config(layout = "wide") # optional
from stlib import countryData
from stlib import continentData
def run():
import streamlit as st
import pandas as pd
import plotly.express as px
df = pd.DataFrame(px.data.gapminder())
# Continents/Country code goes here
# This code allows you to run the app standalone
import streamlit as st
import pandas as pd
import plotly.express as px
st.set_page_config(layout="wide")
df = pd.DataFrame(px.data.gapminder())
def countryData():
# Countries code goes here
# Continents
contlist = df['continent'].unique()
continent = st.selectbox("Select a continent:", contlist)
col1, col2 = st.columns(2)
fig = px.line(df[df['continent'] == continent],
x = "year", y = "gdpPercap",
title = "GDP per Capita",color = 'country')
col1.plotly_chart(fig)
# Countries
clist = df['country'].unique()
country = st.selectbox("Select a country:", clist)
col1, col2 = st.columns(2)
fig = px.line(df[df['country'] == country],
x="year", y="gdpPercap", title="GDP per Capita")
col1.plotly_chart(fig, use_container_width=True)