# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Home Assignment 1

# You should work on the assignement in groups of two students. Upload your solution as a jupyter notebook to moodle by *27th of May 23:59h*. The deadline is strict. Do not forget to specify the names of _all_ contributing students in the jupyter notebook.
#
# Please make sure that your intermediate results follow the required naming conventions, otherwise point deductions will apply.
#
# You should add comments to your code where necessary and print the relevant results.
# You can use code snippets (few lines of code), but you have to cite all your sources! Copying uncited sources or solutions of your fellow students will be (without warning) counted as plagiarism and expulsion from the course.
#
#
#

# ## 1. abgeordnetenwatch.de

# abgeordnetenwatch.de is a website that allows to ask questions to politicians online and receive answers. They also provide an API to obtain data on politicians: https://www.abgeordnetenwatch.de/api/
#
# Use the API to obtain data of all candidates for the state parliament of bavaria. Put together a pandas dataframe with five columns: 
# * first name
# * last name
# * party
# * gender
# * age (you can calculate it from the birthyear)
#
# Store this data frame in a variable called 'df_politicians'. 
#



# What is the most frequent last name in the parliament?



# Compute the gender ratio (i.e., % of female deputies) for each party. Store the results in a dictionary with the name 'gender_ratios' with the party name as key and the percentage of females as value.
#
# Visualize results in a bar chart.



# Compare the age distribution for the green party and the conservative CSU party. 
# For this, plot a semi-transparent histogram (comparable to this: https://i.stack.imgur.com/UI5c0.png) with the age distribution of the two parties



# ## 2. History in Wikipedia

# Download the html text from the article 'History_of_Germany' from the English Wikipedia. Store the results in a string 'full_html'



# Extract all links to other Wikipedia page from this article. Store them in a list called 'all_links' in alphabetical order of the target article name.



# Download the first 10 articles from this list and store the html contents in one string each. Put all strings in a list called 'full_linked_texts'



# Write a function 'extract_years (string_input)' that gets a string and returns how often a certain year number from 1000-2019 occurs. You can assume that each number between 1000 and 2019 is a year number. The result is a dictionary with year numbers as keys, and the number of occurrences as values.
#
# Example: extract_years("The king reigned from 1245 to 1268. He died in 1268.") should return the dictionary {1245: 1, 1268:2}



# Use your function on all 11 downloaded Wikipedia article raw texts to compute the overall number of occurrences for each year number.
# Store the aggregated counts (summarized over all articles) in a dictionary called 'overall_counts'



# Visualize the numbers of occurrences in a timeline.





StarcoderdataJupyterScriptsDedupFiltered