Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tally NBN info into a file #299

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions code/adhoc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,30 @@ def update_historical_tech_and_upgrade_breakdown():
print(tabulate(rows, headers="keys", tablefmt="github"))


def generate_all_suburbs_nbn_tallies():
"""Create a file containing a tally of all suburbs by property (tech, upgrade, etc)"""
exclude_properties = {"name", "locID", "gnaf_pid"}
tallies = {} # property-name -> Counter()
for file in glob.glob("results/**/*.geojson"):
for feature in utils.read_json_file(file)["features"]:
for prop, value in feature["properties"].items():
if prop not in exclude_properties:
if prop not in tallies:
tallies[prop] = Counter()
tallies[prop][value] += 1

# Add percentages and missing items
total_count = sum(tallies["tech"].values()) # everything has a tech+NULL
tallies["percent"] = {}
for prop, kvs in tallies.items():
if prop in {"tech", "upgrade", "percent"}:
continue
kvs["None"] = total_count - sum(kvs.values())
tallies["percent"][prop] = {k: f"{100 * v / total_count:.2f}%" for k, v in kvs.items()}

utils.write_json_file("results/all-suburbs-nbn-tallies.json", tallies, indent=1)


if __name__ == "__main__":
LOGLEVEL = os.environ.get("LOGLEVEL", "INFO").upper()
logging.basicConfig(level=LOGLEVEL, format="%(asctime)s %(levelname)s %(threadName)s %(message)s")
Expand Down