<jupyter_start><jupyter_text>Riksdagen motioner * Denna [Jupyter Notebook](https://github.com/salgo60/open-data-examples/blob/master/Riksdagens%20dokument%20Motioner.ipynb)   * samma men 10000 motioner och [engelska](https://github.com/salgo60/open-data-examples/blob/master/Riksdagens%20dokument%20Motioner-en.ipynb)   * [SFS](https://github.com/salgo60/open-data-examples/blob/master/Riksdagens%20dokument%20SFS.ipynb)  * [KU anmälningar](https://github.com/salgo60/open-data-examples/blob/master/Riksdagens%20dokument%20KU-anm%C3%A4lningar.ipynb)  * [Ledamöter](https://github.com/salgo60/open-data-examples/blob/master/Riksdagens%20ledamöter.ipynb)  * [Dokumenttyper](https://github.com/salgo60/open-data-examples/blob/master/Riksdagens%20dokumenttyper.ipynb)  * [Skapa sökfråga](http://data.riksdagen.se/dokumentlista/)  --> 236258 Motioner* Wikipedia [WikiProject_Sweden/Swedish_Riksdag_documents](https://www.wikidata.org/wiki/Wikidata:WikiProject_Sweden/Swedish_Riksdag_documents) Test H7023008 Motion 2019/20:3008 av Jonas Sjöstedt m.fl. (V)* [text](http://data.riksdagen.se/dokument/H7023008.text) / [html](http://data.riksdagen.se/dokument/H7023008.html) /  [json](http://data.riksdagen.se/dokument/H7023008.json)<jupyter_code>import urllib3, json
import pandas as pd 
http = urllib3.PoolManager() 
pd.set_option("display.max.columns", None) 
urlbase ="http://data.riksdagen.se/dokumentlista/?sok=&doktyp=mot&utformat=json&start="

dftot = pd.DataFrame()
for i in range(1,236258,20):
    url = urlbase + str(i)
    if ((i-1) % 10000) == 0:
       print('*', end='', flush=True)
    r = http.request('GET', url)
    try:
        data = json.loads(r.data)
        dftot = dftot.append(pd.DataFrame(data["dokumentlista"]["dokument"]),sort=False)
    except:
        print("\tError in i=",i," can be html problem") 
dftot.head()

dftot.info()
dftot[['nummer','titel','publicerad','beslutad','datum','summary']] 

dftot.publicerad.unique()
dftot.publicerad.value_counts()
%matplotlib inline  
import matplotlib.pyplot as plt   
plot = dftot.publicerad.value_counts()[1:30].plot.bar(y='counts', figsize=(25, 5)) 
plt.show()
organCount = dftot.organ.value_counts() 
organCount
dftot.undertitel.value_counts()[1:50]
dftot.subtyp.value_counts()
dftot.doktyp.value_counts()
dftot.typ.value_counts()
dftot.rm.value_counts()
dftot.status.value_counts()
dftot.beteckning.value_counts()
dftot.tempbeteckning.value_counts()
dftot.nummer.value_counts()
dftot.score.value_counts()
dftot.sokdata.value_counts()
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
sns.heatmap(dftot.isnull(), 
            yticklabels=False, 
            cbar=False, 
            cmap='viridis')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16077287641268684, 'fraction_numerical': 0.04010207801676996, 'mean_word_length': 5.426229508196721, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 7, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '465584', 'license': 'MIT', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1130, 'n_words': 122, 'path': 'Riksdagens dokument Motioner.ipynb', 'repo_name': 'salgo60/open-data-examples', 'size': '2743'}