Skip to content

Instantly share code, notes, and snippets.

@JoeThunyathep
Created February 22, 2022 10:09
Show Gist options
  • Select an option

  • Save JoeThunyathep/af8ce4c3bdd6bb17c30e4802aee4fe2e to your computer and use it in GitHub Desktop.

Select an option

Save JoeThunyathep/af8ce4c3bdd6bb17c30e4802aee4fe2e to your computer and use it in GitHub Desktop.
import pandas as pd
import matplotlib.pyplot as plt
from sqlalchemy import create_engine
# Connect to database
engine = create_engine(f"postgresql+psycopg2://{user}:{pasw}@{host}:{port}/{db}") # Edit/Add user,pasw,host,port,db here!
# Read data from database
table_name = "stuttgart_ap_time"
table_df = pd.read_sql_table(table_name,con=engine,parse_dates=True)
table_df = table_df.set_index("timestamp")
# Plot
plt.style.use('dark_background')
fig, ax = plt.subplots(1,1,figsize=(10,5))
ax.plot(table_df.loc['2022-02-22 06':,'Terminal 2'], marker='.', linestyle='-', linewidth=0.5,label='Terminal 2')
ax.plot(table_df.loc['2022-02-22 06':,'Terminal 3'], marker='.', linestyle='-', linewidth=0.5,label='Terminal 3')
ax.legend(loc="upper right")
ax.set_title("Stuttgart Airport - SECURITY WAIT TIMES")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment