- Running it locally
- App is not deployed
- Not public
- Full code
import os
import sqlite3
import altair as alt
import streamlit as st
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from sodapy import Socrata
import webbrowser
# Layout configuration
st.set_page_config(layout="wide")
# Title and Header Section
st.markdown("<h1 style='text-align: center; color: black;'>Analysis of Police Incident Reports in Norfolk, Virginia</h1>", unsafe_allow_html=True)
st.markdown("<h2 style='text-align: center; color: black;'>2015 - Present</h2>", unsafe_allow_html=True)
st.caption('Author: Stephen Grassia')
st.subheader("Introduction")
intro_text = ('''The City of Norfolk, Virginia, in-order to be more transparent, publishes a dataset caleld 'Police Incident Reports'.
The data set includes information where an officer is dispatched, and responds to an offense, and a report of a crime is generated.
This project will utilize Pandas, SQLite3, Seaborn, MatPlotLib, and Sodapy to analyze police incidents in the past 5 years.''')
st.write(intro_text)
# Links
if st.button('Data'):
url = f'
webbrowser.open_new_tab(url)
st.divider()
# Table of Contents
st.subheader("Table of Contents")
st.markdown(
"""
## Table of Contents
1. Import Libraries
2. Fetch Data using SodaPy
3. Pre-Processing
- 3.1. Add Month, and Year
- 3.2. Rename Fields
4. Create database, and send data to table
5. Visualizations
"""
)
st.divider()
st.markdown(
"""
## 1. Import Libaries
"""
)
st.write("The first thing that needs to be done is import the necessary libraries")
code = '''def hello():
print("Hello, Streamlit!")'''
st.code(code, language='python')
st.markdown("""
- OS: Built-in python package that interacts with your computer operating system.
- [Pandas](): World-class python package that is used for data manipulation, and visualization.
- [Seaborn](): Built on MatPlotLib, is provides for the creation of attractive, and informative graphs.
- [Numpy](): Python library that provides powerful, and versitile array mathmatical, and computational functions.
- [Sodapy](): Allows the user to connect to government, non-profit, and NGO open data sources.
- [MatPlotLib](): Python library that creates informative, and interactive visualizations.
""")
st.divider()
st.markdown(
"""
## 2. Fetch Data using SodaPy
"""
)
- Streamlit 1.31.0
Python 3.12.1
TypeError: ‘str’ object is not callable
Traceback:
File "C:\Users\_____\AppData\Local\anaconda3\envs\streamlitenv\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 535, in _run_script
exec(code, module.__dict__)File "C:\Users\_____\Desktop\Learning\Norfolk\norfolk.py", line 60, in <module>
st.code(code, language='python')