@digidickinson/

Rank UK petition signatures by country

Python

A script to take a petition, pull out the data for signature by country 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()
country_data = petition_data['data']['attributes']['signatures_by_country']
country_df = pd.DataFrame(country_data)
country_rank = country_df.sort_values(by=['signature_count'], ascending=False)
print(country_rank)