Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import pandas as pd
- import matplotlib.pyplot as plt
- data = requests.get("https://petition.parliament.uk/petitions/241584.json").json()
- df = pd.DataFrame.from_dict(data['data']['attributes']['signatures_by_constituency'])
- df = df.sort_values(by='signature_count', ascending=False)
- df = df.apply(lambda x: x[:40])
- df.plot(kind='barh', x="name", y="signature_count", rot=0)
- plt.tight_layout()
- plt.gca().invert_yaxis()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement