@digidickinson/

Rank UK petition signatures by constituency

Python

A script to take a petition, pull out the data for signature by constituency and sort highest to lowest number of sigs

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
import requests
import pandas as pd
response  = requests.get('https://petition.parliament.uk/petitions/233926.json')
petition_data = response.json()
constituency_data = petition_data['data']['attributes']['signatures_by_constituency']
constituency_df = pd.DataFrame(constituency_data)
constituency_rank = constituency_df.sort_values(by=['signature_count'], ascending=False)
print(constituency_rank)