Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp20008-project-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samantha Garrick
comp20008-project-2
Commits
8392a092
Commit
8392a092
authored
Apr 24, 2021
by
Oliver
Browse files
Options
Downloads
Patches
Plain Diff
Example use of data, producing PM10 24 hour maximum and smoker rate against asthma
parent
a2ca594f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ovi.py
+40
-0
40 additions, 0 deletions
ovi.py
with
40 additions
and
0 deletions
ovi.py
0 → 100644
+
40
−
0
View file @
8392a092
import
pandas
as
pandas
import
matplotlib.pyplot
as
plt
# Retrieve the maximum daily average for 2016 PM10, and then index by the appropriate LGA code
MAX_24HR
=
pandas
.
read_csv
(
"
PM10_MAX_24HR_READING.csv
"
)
PM10_to_LGA
=
pandas
.
read_csv
(
"
PM10_to_LGA.csv
"
)
data
=
MAX_24HR
data
[
"
LGA_CODE_2011
"
]
=
PM10_to_LGA
[
"
LGA_CODE_2011
"
]
data
=
data
.
set_index
(
"
LGA_CODE_2011
"
)
# Add the adult smoker rate to this data
LGA_by_HEALTH
=
pandas
.
read_csv
(
"
LGA_by_HEALTH.csv
"
)
LGA_by_HEALTH
=
LGA_by_HEALTH
.
set_index
(
"
LGA_CODE_2011
"
)
data
[
"
smokers
"
]
=
LGA_by_HEALTH
[
"
smokers
"
]
# Average out all SA2 data for each LGA
SA2_by_DISEASES
=
pandas
.
read_csv
(
"
SA2_by_DISEASES.csv
"
)
SA2_to_LGA
=
pandas
.
read_csv
(
"
SA2_to_LGA.csv
"
)
LGA_by_DISEASES
=
SA2_by_DISEASES
.
join
(
SA2_to_LGA
.
set_index
(
"
SA2_MAINCODE_2011
"
),
on
=
"
SA2_MAINCODE_2011
"
)
LGA_by_DISEASES
=
LGA_by_DISEASES
.
drop
(
"
SA2_MAINCODE_2011
"
,
axis
=
1
)
LGA_by_DISEASES
=
LGA_by_DISEASES
.
groupby
([
"
LGA_CODE_2011
"
]).
mean
()
# Add asthma data
data
[
"
asthma
"
]
=
LGA_by_DISEASES
[
"
asthma
"
]
data
=
data
.
reset_index
()
data
=
data
.
sort_values
([
"
asthma
"
])
fig
,
ax
=
plt
.
subplots
()
# Maximum PM10 24 hour average against asthma incidence for local government area
pl1
=
ax
.
scatter
(
data
[
"
asthma
"
],
data
[
"
value
"
],
c
=
"
b
"
)
ax
.
set_ylabel
(
"
Maximum PM10 24 hour reading (2016, μg/m³)
"
,
color
=
"
blue
"
)
ax
.
set_xlabel
(
"
Asthma incidence (percentage)
"
)
fig
.
savefig
(
"
ovi_asthma_vs_pm1024hr.png
"
,
bbox_inches
=
'
tight
'
)
# Now add against smoker rate
ax2
=
ax
.
twinx
()
pl2
=
ax2
.
scatter
(
data
[
"
asthma
"
],
data
[
"
smokers
"
],
c
=
"
r
"
)
ax2
.
set_ylabel
(
"
Adult smokers rate (percentage)
"
,
color
=
"
red
"
)
fig
.
savefig
(
"
ovi_asthma_vs_pm1024hr_smokers.png
"
,
bbox_inches
=
'
tight
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment