Skip to content

Commit

Permalink
Updates with README
Browse files Browse the repository at this point in the history
  • Loading branch information
bcwin-i committed Apr 3, 2024
1 parent 66b6fa1 commit dda6165
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 91 deletions.
166 changes: 166 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
.message.py
test3.py
# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.DS_Store
/api/slackData/

node_modules/
settings.json
182 changes: 91 additions & 91 deletions Dash-Plotly/covid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,106 +8,106 @@

df = pd.read_csv("cleaned_data.csv")

# df["Total_Tests"] = pd.to_numeric(df["Total_Tests"], errors="coerce")
# df["Population(pop)"] = pd.to_numeric(df["Population(pop)"], errors="coerce")
df["Total_Tests"] = pd.to_numeric(df["Total_Tests"], errors="coerce")
df["Population(pop)"] = pd.to_numeric(df["Population(pop)"], errors="coerce")

# df["Recovery_Rate"] = df["Recovered"] / df["Total_Cases"]
df["Recovery_Rate"] = df["Recovered"] / df["Total_Cases"]

# top_countries_recovery_rate = df.sort_values("Recovery_Rate", ascending=False).head(10)
top_countries_recovery_rate = df.sort_values("Recovery_Rate", ascending=False).head(10)

# app = dash.Dash(__name__)
app = dash.Dash(__name__)

# fig_total_cases = px.bar(
# df.sort_values("Total_Cases", ascending=False).head(10),
# x="Country",
# y="Total_Cases",
# title="Top 10 Countries by Total COVID-19 Cases",
# )
fig_total_cases = px.bar(
df.sort_values("Total_Cases", ascending=False).head(10),
x="Country",
y="Total_Cases",
title="Top 10 Countries by Total COVID-19 Cases",
)

# fig_total_deaths_pie = px.pie(
# df.sort_values("Total_Deaths", ascending=False).head(10),
# values="Total_Deaths",
# names="Country",
# title="Top 10 Countries with the most recorded Deaths",
# )
# fig_recovery_rate_line = px.line(
# top_countries_recovery_rate,
# x="Country",
# y="Recovery_Rate",
# title="Top 10 Countries by COVID-19 Recovery Rate",
# )
# stacked_bar_data = df.sort_values("Total_Cases", ascending=False).head(20)[
# ["Country", "Active_Cases", "Recovered", "Total_Deaths"]
# ]
# fig_stacked_bar = px.bar(
# stacked_bar_data,
# x="Country",
# y=["Active_Cases", "Recovered", "Total_Deaths"],
# title="Top 20 Countries by (Active, Recovered, Deaths)",
# barmode="stack",
# )
fig_total_deaths_pie = px.pie(
df.sort_values("Total_Deaths", ascending=False).head(10),
values="Total_Deaths",
names="Country",
title="Top 10 Countries with the most recorded Deaths",
)
fig_recovery_rate_line = px.line(
top_countries_recovery_rate,
x="Country",
y="Recovery_Rate",
title="Top 10 Countries by COVID-19 Recovery Rate",
)
stacked_bar_data = df.sort_values("Total_Cases", ascending=False).head(20)[
["Country", "Active_Cases", "Recovered", "Total_Deaths"]
]
fig_stacked_bar = px.bar(
stacked_bar_data,
x="Country",
y=["Active_Cases", "Recovered", "Total_Deaths"],
title="Top 20 Countries by (Active, Recovered, Deaths)",
barmode="stack",
)

# fig_critical_cases = px.bar(
# df.sort_values("Critical_Cases", ascending=False).head(10),
# x="Country",
# y="Critical_Cases",
# title="Top 10 Countries with high Critical Cases",
# )
# fig_bubble = px.scatter(
# df,
# x="Total_Cases",
# y="Total_Deaths",
# size="Recovered",
# color="Country",
# hover_name="Country",
# log_x=True,
# log_y=True,
# title="Total Cases vs Total Deaths (Bubble Chart)",
# labels={
# "Total_Cases": "Total Cases",
# "Total_Deaths": "Total Deaths",
# },
# )
fig_critical_cases = px.bar(
df.sort_values("Critical_Cases", ascending=False).head(10),
x="Country",
y="Critical_Cases",
title="Top 10 Countries with high Critical Cases",
)
fig_bubble = px.scatter(
df,
x="Total_Cases",
y="Total_Deaths",
size="Recovered",
color="Country",
hover_name="Country",
log_x=True,
log_y=True,
title="Total Cases vs Total Deaths (Bubble Chart)",
labels={
"Total_Cases": "Total Cases",
"Total_Deaths": "Total Deaths",
},
)


# app.layout = html.Div(
# [
# html.H1("COVID-19 Data Visualization"),
# dcc.Dropdown(
# id="metric-dropdown",
# options=[
# {"label": "Total Cases", "value": "Total_Cases"},
# {"label": "Total Deaths", "value": "Total_Deaths"},
# {"label": "Total Recoveries", "value": "Recovered"},
# ],
# value="Total_Cases",
# ),
# dcc.Graph(id="covid-graph"),
# html.Hr(), # Adding a horizontal line for separation
# html.H2("Top 10 Countries by Various Metrics"),
# dcc.Graph(figure=fig_total_cases, id="fig_total_cases"),
# dcc.Graph(figure=fig_total_deaths_pie, id="fig_total_deaths_pie"),
# dcc.Graph(figure=fig_recovery_rate_line, id="fig_recovery_rate_line"),
# dcc.Graph(figure=fig_stacked_bar, id="fig_stacked_bar"),
# dcc.Graph(figure=fig_critical_cases, id="fig_critical_cases"),
# dcc.Graph(figure=fig_bubble, id="fig_bubble"),
# ]
# )
app.layout = html.Div(
[
html.H1("COVID-19 Data Visualization"),
dcc.Dropdown(
id="metric-dropdown",
options=[
{"label": "Total Cases", "value": "Total_Cases"},
{"label": "Total Deaths", "value": "Total_Deaths"},
{"label": "Total Recoveries", "value": "Recovered"},
],
value="Total_Cases",
),
dcc.Graph(id="covid-graph"),
html.Hr(), # Adding a horizontal line for separation
html.H2("Top 10 Countries by Various Metrics"),
dcc.Graph(figure=fig_total_cases, id="fig_total_cases"),
dcc.Graph(figure=fig_total_deaths_pie, id="fig_total_deaths_pie"),
dcc.Graph(figure=fig_recovery_rate_line, id="fig_recovery_rate_line"),
dcc.Graph(figure=fig_stacked_bar, id="fig_stacked_bar"),
dcc.Graph(figure=fig_critical_cases, id="fig_critical_cases"),
dcc.Graph(figure=fig_bubble, id="fig_bubble"),
]
)


# @app.callback(Output("covid-graph", "figure"), [Input("metric-dropdown", "value")])
# def update_graph(selected_metric):
# choro = px.choropleth(
# df,
# locations="Country",
# locationmode="country names",
# color=selected_metric,
# hover_name="Country",
# title=f"COVID-19 {selected_metric} by Country",
# labels={selected_metric: "Number recorded"},
# )
# return choro
@app.callback(Output("covid-graph", "figure"), [Input("metric-dropdown", "value")])
def update_graph(selected_metric):
choro = px.choropleth(
df,
locations="Country",
locationmode="country names",
color=selected_metric,
hover_name="Country",
title=f"COVID-19 {selected_metric} by Country",
labels={selected_metric: "Number recorded"},
)
return choro


# if __name__ == "__main__":
# app.run(port=4050, debug=True)
if __name__ == "__main__":
app.run(port=4050, debug=True)
Loading

0 comments on commit dda6165

Please sign in to comment.