Examples
The examples/ directory in the repository contains a number of ready-to-run scripts and notebooks.
Table of contents
- Scripts
- Jupyter Notebooks
- Quick Example: List Councillors
- Quick Example: Search Speeches
- Quick Example: Plot Voting Results
Scripts
Jupyter Notebooks
Quick Example: List Councillors
import swissparlpy as spp
councillors = spp.get_data('MemberCouncil', Language='DE', CantonAbbreviation='ZH')
for c in councillors:
print(f"{c['FirstName']} {c['LastName']}")
Quick Example: Search Speeches
import swissparlpy as spp
opd_client = spp.SwissParlClient(backend="openparldata")
response = opd_client.get_data(
"speeches",
search_mode="natural",
search_scope="all",
search_language="de",
search="Klimawandel"
)
df = response.to_dataframe()
print(df[["id", "date_start", "text_content_de"]].head())
Quick Example: Plot Voting Results
import swissparlpy as spp
votes = spp.get_data('Vote', Language='DE', IdVotingNumber=24189)
spp.plot_voting(votes)