#required imports

import gzip
import json
import re
import mwapi
import pandas as pd
#launch session with MediaWikiAPI

session = mwapi.Session(host='https://en.wikipedia.org',
                        user_agent='mwapi (python) -- outreachy content translation')

# obtain articles translated from English to Spanish
parameters_es = {'action':'query',
              'format':'json',
              'list':'cxpublishedtranslations',
              'from':'en',
              'to':'es',
              'limit':500,
              'offset':20000}

# obtain articles translated from English to French
parameters_fr = {'action':'query',
              'format':'json',
              'list':'cxpublishedtranslations',
              'from':'en',
              'to':'fr',
              'limit':500,
              'offset':20000}
#Got data for both sets of translations

res_es = session.get(parameters_es)
res_fr = session.get(parameters_fr)

Translated articles over which quantitative analysis has been done

SPANISH

df_es = pd.DataFrame(res_es['result']['translations'])
df_es.head(10)
publishedDate sourceLanguage sourceRevisionId sourceTitle sourceURL stats targetLanguage targetRevisionId targetTitle targetURL translationId
0 20170928184257 en 801947468 Los Americans //en.wikipedia.org/wiki/Los Americans {'any': 0.94256474519632, 'human': 0.029866332... es 102209427 Usuario:Ivonnejo04/Los Americans //es.wikipedia.org/wiki/Los Americans 374559
1 20170928215416 en 802832925 American Vandal //en.wikipedia.org/wiki/American Vandal {'any': 0.21890547263682, 'human': 0.084920226... es 102214615 Usuario:Misaelflorezav/American Vandal //es.wikipedia.org/wiki/Usuario:Misaelflorezav... 374655
2 20170928221445 en 746876472 End Records //en.wikipedia.org/wiki/End Records {'any': 1.1047708138447, 'human': 1.1047708138... es 102215116 End Records //es.wikipedia.org/wiki/End Records 374660
3 20170928223045 en 797871239 60S ribosomal protein L10 //en.wikipedia.org/wiki/60S ribosomal protein L10 {'any': 0.27921220127297, 'human': 0.274768824... es 102215432 Proteína L10 de la unidad ribosómica 60S //es.wikipedia.org/wiki/Proteína L10 de la uni... 374661
4 20170928222819 en 796534066 Ned Washington //en.wikipedia.org/wiki/Ned Washington {'any': 1.0329474621549, 'human': 1.0255268625... es 102215375 Ned Washington //es.wikipedia.org/wiki/Ned Washington 374663
5 20170928233753 en 797738429 Greek legislative election, 1936 //en.wikipedia.org/wiki/Greek legislative elec... {'any': 0.74281709880869, 'human': 0.728100911... es 102216616 Elecciones parlamentarias de Grecia de 1936 //es.wikipedia.org/wiki/Elecciones parlamentar... 374674
6 20170928235113 en 787160410 Maltese general election, 1927 //en.wikipedia.org/wiki/Maltese general electi... {'any': 0.94422310756972, 'human': 0.893227091... es 102216883 Elecciones generales de Malta de 1927 //es.wikipedia.org/wiki/Elecciones generales d... 374675
7 20170929060104 en 801281364 Dançando //en.wikipedia.org/wiki/Dançando {'any': 0.86393027832443, 'human': 0.857042451... es 102222244 Dançando //es.wikipedia.org/wiki/Dançando 374719
8 20170929080018 en 802912035 BFR (rocket) //en.wikipedia.org/wiki/BFR (rocket) {'any': 0.014279624893436, 'human': 0.00078147... es 102223820 BFR (cohete) //es.wikipedia.org/wiki/BFR (cohete) 374751
9 20170929150431 en 774931364 MatrixNet //en.wikipedia.org/wiki/MatrixNet {'any': 0.61847988077496, 'human': 0.552906110... es 102229789 MatrixNet //es.wikipedia.org/wiki/MatrixNet 374858

FRENCH

df_fr = pd.DataFrame(res_fr['result']['translations'])
df_fr.head(10)
publishedDate sourceLanguage sourceRevisionId sourceTitle sourceURL stats targetLanguage targetRevisionId targetTitle targetURL translationId
0 20180411213718 en 722570847 Katharine Russell, Viscountess Amberley //en.wikipedia.org/wiki/Katharine Russell, Vis... {'any': 0.11680327868852, 'human': 0.114071038... fr 147440088 Katharine Russell, Viscomtesse Amberley //fr.wikipedia.org/wiki/Katharine Russell, Vis... 458130
1 20180411213549 en 774168495 Patricia Russell, Countess Russell //en.wikipedia.org/wiki/Patricia Russell, Coun... {'any': 0.35788262370541, 'human': 0.286536248... fr 147440343 Patricia Russell, comtesse Russell //fr.wikipedia.org/wiki/Patricia Russell, comt... 458134
2 20180411213942 en 822219566 Edith Finch Russell //en.wikipedia.org/wiki/Edith Finch Russell {'any': 0.4467668190725, 'human': 0.1998693664... fr 147440457 Edith Finch Russell //fr.wikipedia.org/wiki/Edith Finch Russell 458135
3 20180411214539 en 833300535 Paatsaali School //en.wikipedia.org/wiki/Paatsaali School {'any': 0.23483870967742, 'human': 0.234838709... fr 147440614 Paatsaali School //fr.wikipedia.org/wiki/Paatsaali School 458138
4 20180411215721 en 835896198 Tiyas Military Airbase //en.wikipedia.org/wiki/Tiyas Military Airbase {'any': 0.64448105436573, 'human': 0, 'mt': 0.... fr 147440740 Tiyas Military Airbase //fr.wikipedia.org/wiki/Tiyas Military Airbase 458140
5 20180412113152 en 832284246 HMS Pakenham (G06) //en.wikipedia.org/wiki/HMS Pakenham (G06) {'any': 0.7489837398374, 'human': 0.7191056910... fr 147453599 HMS Pakenham (G06) //fr.wikipedia.org/wiki/HMS Pakenham (G06) 458143
6 20180412054443 en 801380283 Augusto Aurelio Fábrega Donado //en.wikipedia.org/wiki/Augusto Aurelio Fábreg... {'any': 0.77176015473888, 'human': 0.593810444... fr 147445484 Augusto Aurelio Fábrega Donado //fr.wikipedia.org/wiki/Augusto Aurelio Fábreg... 458212
7 20180412065849 en 819466284 Fatima Abdel Mahmoud //en.wikipedia.org/wiki/Fatima Abdel Mahmoud {'any': 1.0772946859903, 'human': 1.0524499654... fr 147446585 Fatima Abdel Mahmoud //fr.wikipedia.org/wiki/Fatima Abdel Mahmoud 458222
8 20180412072207 en 834100040 Arjun Bahadur Thapa //en.wikipedia.org/wiki/Arjun Bahadur Thapa {'any': 0.62175525339926, 'human': 0.520086526... fr 147446955 Arjun Bahadur Thapa //fr.wikipedia.org/wiki/Arjun Bahadur Thapa 458234
9 20180412073159 en 829889493 Blonde joke //en.wikipedia.org/wiki/Blonde joke {'any': 0.43057536852116, 'human': 0.393961008... fr 147447127 Utilisateur:Michel1961/Blagues sur les blondes //fr.wikipedia.org/wiki/Utilisateur:Michel1961... 458235

Converting titles to lists and linking source and target titles via dictionaries.

sourcetitles_es = df_es.head(10)['sourceTitle'].tolist()
targettitles_es = df_es.head(10)['targetTitle'].tolist()

sourcetitles_fr = df_fr.head(10)['sourceTitle'].tolist()
targettitles_fr = df_fr.head(10)['targetTitle'].tolist()
##To replace spaces in titles with underscores for future analysis

##SPANISH
sourcetitles_new_es = []
targettitles_new_es = []

for word in sourcetitles_es:
    word = word.replace(" ", "_")
    sourcetitles_new_es.append(word)
    
for word in targettitles_es:
    word = word.replace(" ", "_")
    targettitles_new_es.append(word)
            

##FRENCH        
sourcetitles_new_fr = []
targettitles_new_fr = []

for word in sourcetitles_fr:
    word = word.replace(" ", "_")
    sourcetitles_new_fr.append(word)
    
for word in targettitles_fr:
    word = word.replace(" ", "_")
    targettitles_new_fr.append(word)
##Forming dictionaries for source title as key and target title as value

##Spanish
titledict_es = {}
i = 0

while i < len(df_es):
    titledict_es[df_es.loc[i,'sourceTitle']] = df_es.loc[i,'targetTitle']
    i = i+1

##French    
titledict_fr= {}
i = 0

while i < len(df_fr):
    titledict_fr[df_fr.loc[i,'sourceTitle']] = df_fr.loc[i,'targetTitle']
    i = i+1
##Forming dictionaries for source title as key and target title as value - for titles with underscores

##Spanish
titledict_new_es = {}
i = 0

while i < len(sourcetitles_new_es):
    titledict_new_es[sourcetitles_new_es[i]] = targettitles_new_es[i]
    i = i+1
    
##French
titledict_new_fr = {}
i = 0

while i < len(sourcetitles_new_fr):
    titledict_new_fr[sourcetitles_new_fr[i]] = targettitles_new_fr[i]
    i = i+1

Quantitative Analysis Part 1: Page Views

#installing media wiki utilities required for page view data

!pip install git+https://github.com/mediawiki-utilities/python-mwviews.git
Collecting git+https://github.com/mediawiki-utilities/python-mwviews.git
  Cloning https://github.com/mediawiki-utilities/python-mwviews.git to /tmp/pip-dps86va3-build
  Ignoring futures: markers 'python_version < "3.0"' don't match your environment
Requirement already satisfied: requests in /srv/paws/lib/python3.6/site-packages (from mwviews==0.1.0)
Requirement already satisfied: mwcli in /srv/paws/lib/python3.6/site-packages (from mwviews==0.1.0)
Requirement already satisfied: mwapi in /srv/paws/lib/python3.6/site-packages (from mwviews==0.1.0)
Requirement already satisfied: idna<2.8,>=2.5 in /srv/paws/lib/python3.6/site-packages (from requests->mwviews==0.1.0)
Requirement already satisfied: certifi>=2017.4.17 in /srv/paws/lib/python3.6/site-packages (from requests->mwviews==0.1.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /srv/paws/lib/python3.6/site-packages (from requests->mwviews==0.1.0)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /srv/paws/lib/python3.6/site-packages (from requests->mwviews==0.1.0)
Requirement already satisfied: docopt in /srv/paws/lib/python3.6/site-packages (from mwcli->mwviews==0.1.0)
Requirement already satisfied: para in /srv/paws/lib/python3.6/site-packages (from mwcli->mwviews==0.1.0)
Installing collected packages: mwviews
  Running setup.py install for mwviews ... done
Successfully installed mwviews-0.1.0
import mwviews
from mwviews.api import PageviewsClient
#import pretty printer for printing scattered data 

import pprint
pp = pprint.PrettyPrinter(indent = 2)

EN -> ES

Page Views for English Wiki pages for 5 articles

p_es = PageviewsClient(user_agent = None)

p1_es = p_es.article_views('en.wikipedia', sourcetitles_es[:5])
pp.pprint(p_es.article_views('en.wikipedia', sourcetitles_es[:5]))
defaultdict(<class 'dict'>,
            { datetime.datetime(2019, 2, 28, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                      'American_Vandal': 1402,
                                                      'End_Records': 10,
                                                      'Los_Americans': 7,
                                                      'Ned_Washington': 65},
              datetime.datetime(2019, 3, 1, 0, 0): { '60S_ribosomal_protein_L10': 6,
                                                     'American_Vandal': 1254,
                                                     'End_Records': 14,
                                                     'Los_Americans': 2,
                                                     'Ned_Washington': 51},
              datetime.datetime(2019, 3, 2, 0, 0): { '60S_ribosomal_protein_L10': 5,
                                                     'American_Vandal': 1459,
                                                     'End_Records': 5,
                                                     'Los_Americans': 2,
                                                     'Ned_Washington': 54},
              datetime.datetime(2019, 3, 3, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                     'American_Vandal': 1615,
                                                     'End_Records': 7,
                                                     'Los_Americans': 10,
                                                     'Ned_Washington': 65},
              datetime.datetime(2019, 3, 4, 0, 0): { '60S_ribosomal_protein_L10': 1,
                                                     'American_Vandal': 1617,
                                                     'End_Records': 10,
                                                     'Los_Americans': 2,
                                                     'Ned_Washington': 68},
              datetime.datetime(2019, 3, 5, 0, 0): { '60S_ribosomal_protein_L10': 10,
                                                     'American_Vandal': 1358,
                                                     'End_Records': 6,
                                                     'Los_Americans': 10,
                                                     'Ned_Washington': 57},
              datetime.datetime(2019, 3, 6, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                     'American_Vandal': 1205,
                                                     'End_Records': 4,
                                                     'Los_Americans': 7,
                                                     'Ned_Washington': 67},
              datetime.datetime(2019, 3, 7, 0, 0): { '60S_ribosomal_protein_L10': 2,
                                                     'American_Vandal': 1276,
                                                     'End_Records': 6,
                                                     'Los_Americans': 9,
                                                     'Ned_Washington': 52},
              datetime.datetime(2019, 3, 8, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                     'American_Vandal': 1241,
                                                     'End_Records': 5,
                                                     'Los_Americans': 5,
                                                     'Ned_Washington': 69},
              datetime.datetime(2019, 3, 9, 0, 0): { '60S_ribosomal_protein_L10': 1,
                                                     'American_Vandal': 1444,
                                                     'End_Records': 7,
                                                     'Los_Americans': 12,
                                                     'Ned_Washington': 76},
              datetime.datetime(2019, 3, 10, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                      'American_Vandal': 1810,
                                                      'End_Records': 9,
                                                      'Los_Americans': 4,
                                                      'Ned_Washington': 80},
              datetime.datetime(2019, 3, 11, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                      'American_Vandal': 1934,
                                                      'End_Records': 5,
                                                      'Los_Americans': 10,
                                                      'Ned_Washington': 67},
              datetime.datetime(2019, 3, 12, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                      'American_Vandal': 1994,
                                                      'End_Records': 9,
                                                      'Los_Americans': 9,
                                                      'Ned_Washington': 63},
              datetime.datetime(2019, 3, 13, 0, 0): { '60S_ribosomal_protein_L10': 6,
                                                      'American_Vandal': 1968,
                                                      'End_Records': 3,
                                                      'Los_Americans': 12,
                                                      'Ned_Washington': 75},
              datetime.datetime(2019, 3, 14, 0, 0): { '60S_ribosomal_protein_L10': 6,
                                                      'American_Vandal': 1736,
                                                      'End_Records': 5,
                                                      'Los_Americans': 11,
                                                      'Ned_Washington': 85},
              datetime.datetime(2019, 3, 15, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                      'American_Vandal': 1701,
                                                      'End_Records': 3,
                                                      'Los_Americans': 8,
                                                      'Ned_Washington': 79},
              datetime.datetime(2019, 3, 16, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                      'American_Vandal': 1792,
                                                      'End_Records': 9,
                                                      'Los_Americans': 4,
                                                      'Ned_Washington': 74},
              datetime.datetime(2019, 3, 17, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                      'American_Vandal': 1893,
                                                      'End_Records': 6,
                                                      'Los_Americans': 3,
                                                      'Ned_Washington': 84},
              datetime.datetime(2019, 3, 18, 0, 0): { '60S_ribosomal_protein_L10': 2,
                                                      'American_Vandal': 2084,
                                                      'End_Records': 9,
                                                      'Los_Americans': 4,
                                                      'Ned_Washington': 93},
              datetime.datetime(2019, 3, 19, 0, 0): { '60S_ribosomal_protein_L10': 2,
                                                      'American_Vandal': 2148,
                                                      'End_Records': 6,
                                                      'Los_Americans': 11,
                                                      'Ned_Washington': 103},
              datetime.datetime(2019, 3, 20, 0, 0): { '60S_ribosomal_protein_L10': 1,
                                                      'American_Vandal': 1853,
                                                      'End_Records': 6,
                                                      'Los_Americans': 9,
                                                      'Ned_Washington': 80},
              datetime.datetime(2019, 3, 21, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                      'American_Vandal': 1673,
                                                      'End_Records': 7,
                                                      'Los_Americans': 5,
                                                      'Ned_Washington': 68},
              datetime.datetime(2019, 3, 22, 0, 0): { '60S_ribosomal_protein_L10': 4,
                                                      'American_Vandal': 1627,
                                                      'End_Records': 13,
                                                      'Los_Americans': 7,
                                                      'Ned_Washington': 79},
              datetime.datetime(2019, 3, 23, 0, 0): { '60S_ribosomal_protein_L10': 2,
                                                      'American_Vandal': 1451,
                                                      'End_Records': 19,
                                                      'Los_Americans': 10,
                                                      'Ned_Washington': 60},
              datetime.datetime(2019, 3, 24, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                      'American_Vandal': 2209,
                                                      'End_Records': 7,
                                                      'Los_Americans': 9,
                                                      'Ned_Washington': 70},
              datetime.datetime(2019, 3, 25, 0, 0): { '60S_ribosomal_protein_L10': 6,
                                                      'American_Vandal': 2185,
                                                      'End_Records': 7,
                                                      'Los_Americans': 13,
                                                      'Ned_Washington': 67},
              datetime.datetime(2019, 3, 26, 0, 0): { '60S_ribosomal_protein_L10': 5,
                                                      'American_Vandal': 1500,
                                                      'End_Records': 2,
                                                      'Los_Americans': 12,
                                                      'Ned_Washington': 63},
              datetime.datetime(2019, 3, 27, 0, 0): { '60S_ribosomal_protein_L10': 5,
                                                      'American_Vandal': 1462,
                                                      'End_Records': 9,
                                                      'Los_Americans': 4,
                                                      'Ned_Washington': 59},
              datetime.datetime(2019, 3, 28, 0, 0): { '60S_ribosomal_protein_L10': 9,
                                                      'American_Vandal': 1303,
                                                      'End_Records': 6,
                                                      'Los_Americans': 6,
                                                      'Ned_Washington': 72},
              datetime.datetime(2019, 3, 29, 0, 0): { '60S_ribosomal_protein_L10': 3,
                                                      'American_Vandal': 1205,
                                                      'End_Records': 7,
                                                      'Los_Americans': 9,
                                                      'Ned_Washington': 91},
              datetime.datetime(2019, 3, 30, 0, 0): { '60S_ribosomal_protein_L10': None,
                                                      'American_Vandal': None,
                                                      'End_Records': None,
                                                      'Los_Americans': None,
                                                      'Ned_Washington': None}})

Page Views for corresponding Spanish Wiki pages over same time

p2_es = p_es.article_views('es.wikipedia', targettitles_es[:5])
pp.pprint(p_es.article_views('es.wikipedia', targettitles_es[:5]))
defaultdict(<class 'dict'>,
            { datetime.datetime(2019, 2, 28, 0, 0): { 'End_Records': 4,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 1, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': None,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 2, 0, 0): { 'End_Records': 1,
                                                     'Ned_Washington': None,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 3, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': 1,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 4, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': 5,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 5, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': None,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 6, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': 1,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 7, 0, 0): { 'End_Records': 1,
                                                     'Ned_Washington': 2,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 8, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': 2,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': 1},
              datetime.datetime(2019, 3, 9, 0, 0): { 'End_Records': None,
                                                     'Ned_Washington': None,
                                                     'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                     'Usuario:Ivonnejo04/Los_Americans': None,
                                                     'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 10, 0, 0): { 'End_Records': 4,
                                                      'Ned_Washington': 4,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 11, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 12, 0, 0): { 'End_Records': 1,
                                                      'Ned_Washington': 6,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 13, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 14, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 5,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 15, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': None,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 16, 0, 0): { 'End_Records': 1,
                                                      'Ned_Washington': 1,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 17, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 18, 0, 0): { 'End_Records': 2,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 19, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': None,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 20, 0, 0): { 'End_Records': 2,
                                                      'Ned_Washington': 3,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 21, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 1,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 22, 0, 0): { 'End_Records': 1,
                                                      'Ned_Washington': 4,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 23, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 24, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 1,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': 1},
              datetime.datetime(2019, 3, 25, 0, 0): { 'End_Records': 2,
                                                      'Ned_Washington': 4,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 26, 0, 0): { 'End_Records': 1,
                                                      'Ned_Washington': 2,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 27, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 4,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 28, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': None,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 29, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': 3,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None},
              datetime.datetime(2019, 3, 30, 0, 0): { 'End_Records': None,
                                                      'Ned_Washington': None,
                                                      'Proteína_L10_de_la_unidad_ribosómica_60S\xa0': None,
                                                      'Usuario:Ivonnejo04/Los_Americans': None,
                                                      'Usuario:Misaelflorezav/American_Vandal': None}})

Comparison of Page Views for the English and Spanish versions of 5 pages. (Over a month)

import numpy as np
import matplotlib.pyplot as plt

l1 = []
l2 = []

l0 = [x for x in range(31)]    
lim = 0   #to compare only 5 articles

for s in sourcetitles_new_es:
    l1 = []
    l2 = []
    for k1 in p1_es:
        dict1 = p1_es[k1]
        dict2 = p2_es[k1]
        l1.append(dict1[s])    #l1 stores date-wise page views of English Version of article
        if dict2[titledict_new_es[s]] == None:
            l2.append(0)
        else:
            l2.append(dict2[titledict_new_es[s]])    #l2 stores date-wise page views of Spanish Version of article
        
     
    
    #plotting graphs
    print("Name of Article: English -> ", s, " Spanish -> ", titledict_new_es[s])
    plt_eng, = plt.plot(l0, l1, label = 'english')
    plt_esp, = plt.plot(l0, l2, label = 'spanish')
    plt.legend(handles=[plt_eng, plt_esp])
    plt.xlabel('Days')
    plt.ylabel('Views')
   
    plt.show() 
    
    plt.clf()
    lim = lim + 1
    if lim == 5:
        break
Name of Article: English ->  Los_Americans  Spanish ->  Usuario:Ivonnejo04/Los_Americans
Name of Article: English ->  American_Vandal  Spanish ->  Usuario:Misaelflorezav/American_Vandal
Name of Article: English ->  End_Records  Spanish ->  End_Records
Name of Article: English ->  60S_ribosomal_protein_L10  Spanish ->  Proteína_L10_de_la_unidad_ribosómica_60S 
Name of Article: English ->  Ned_Washington  Spanish ->  Ned_Washington
<Figure size 432x288 with 0 Axes>

EN -> FR

#same process repeated for French translations

p_fr = PageviewsClient(user_agent = None)

p1_fr = p_fr.article_views('en.wikipedia', sourcetitles_fr[:5])
p2_fr = p_fr.article_views('fr.wikipedia', targettitles_fr[:5])

l1 = []
l2 = []

l0 = [x for x in range(31)]    
lim = 0
for s in sourcetitles_new_fr:
    l1 = []
    l2 = []
    for k1 in p1_fr:
        dict1 = p1_fr[k1]
        dict2 = p2_fr[k1]
        l1.append(dict1[s])               #l1 stores date-wise page views of English Version of article
        if dict2[titledict_new_fr[s]] == None:
            l2.append(0)
        else:
            l2.append(dict2[titledict_new_fr[s]])       #l2 stores date-wise page views of French Version of article
        
     
    #plotting graphs
    print("Name of Article: English -> ", s, " French -> ", titledict_new_fr[s])
    plt_eng, = plt.plot(l0, l1, label = 'english')
    plt_esp, = plt.plot(l0, l2, label = 'french')
    plt.legend(handles=[plt_eng, plt_esp])
    plt.xlabel('Days')
    plt.ylabel('Views')
   
    plt.show() 
    
    plt.clf()
    lim = lim + 1
    if lim == 5:
        break
Name of Article: English ->  Katharine_Russell,_Viscountess_Amberley  French ->  Katharine_Russell,_Viscomtesse_Amberley
Name of Article: English ->  Patricia_Russell,_Countess_Russell  French ->  Patricia_Russell,_comtesse_Russell
Name of Article: English ->  Edith_Finch_Russell  French ->  Edith_Finch_Russell
Name of Article: English ->  Paatsaali_School  French ->  Paatsaali_School
Name of Article: English ->  Tiyas_Military_Airbase  French ->  Tiyas_Military_Airbase
<Figure size 432x288 with 0 Axes>

Quantitative Analysis Part 2: Page History

EN->ES

Page History: English Wiki Pages

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

#generate title string with all titles separated with "|"
title_str_es = ""
for s in sourcetitles_es[:5]:
    if s == sourcetitles_es[4]:
        title_str_es += s
    else:
        title_str_es += s + "|"
        
#set parameters
        
PARAMS = {
    "action": "query",
    "prop": "revisions",
    "titles": title_str_es,
    "rvprop": "timestamp|user",
    "rvslots": "main",
    "formatversion": "2",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA_es = R.json()

#print(DATA)
DATA_es.keys()
dict_keys(['batchcomplete', 'query'])
#pretty printing page history of 5 Wiki Articles in English
pp.pprint(DATA_es)
{ 'batchcomplete': True,
  'query': { 'pages': [ { 'ns': 0,
                          'pageid': 770812,
                          'revisions': [ { 'anon': True,
                                           'timestamp': '2019-03-15T02:35:51Z',
                                           'user': '2600:1700:3700:1DA0:5DAD:EDAF:FAA3:76F2'}],
                          'title': 'Ned Washington'},
                        { 'ns': 0,
                          'pageid': 1150360,
                          'revisions': [ { 'timestamp': '2016-10-30T03:11:36Z',
                                           'user': 'Bender the Bot'}],
                          'title': 'End Records'},
                        { 'ns': 0,
                          'pageid': 14760404,
                          'revisions': [ { 'timestamp': '2017-08-29T17:15:52Z',
                                           'user': 'KolbertBot'}],
                          'title': '60S ribosomal protein L10'},
                        { 'ns': 0,
                          'pageid': 50963199,
                          'revisions': [ { 'timestamp': '2018-12-08T09:29:28Z',
                                           'user': 'Marcocapelle'}],
                          'title': 'Los Americans'},
                        { 'ns': 0,
                          'pageid': 55168487,
                          'revisions': [ { 'anon': True,
                                           'timestamp': '2019-03-03T17:52:26Z',
                                           'user': '74.103.37.6'}],
                          'title': 'American Vandal'}]}}

Page History: Corresponding Spanish Wiki Pages

#similarly for corresponding spanish pages

import requests

S = requests.Session()

URL = "https://es.wikipedia.org/w/api.php"

title_str_target_es = ""
for s in targettitles_es[:5]:
    if s == targettitles_es[4]:
        title_str_target_es += s
    else:
        title_str_target_es += s + "|"

#setting parameters
        
PARAMS = {
    "action": "query",
    "prop": "revisions",
    "titles": title_str_target_es,
    "rvprop": "timestamp|user",
    "rvslots": "main",
    "formatversion": "2",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA_es_target = R.json()

#print(DATA)
DATA_es_target.keys()
dict_keys(['batchcomplete', 'query'])
#pretty printing page history of 5 Wiki Articles in Spanish

pp.pprint(DATA_es_target)
{ 'batchcomplete': True,
  'query': { 'normalized': [ { 'from': 'Proteína L10 de la unidad ribosómica '
                                       '60S\xa0',
                               'fromencoded': False,
                               'to': 'Proteína L10 de la unidad ribosómica '
                                     '60S'}],
             'pages': [ { 'missing': True,
                          'ns': 2,
                          'title': 'Usuario:Ivonnejo04/Los Americans'},
                        { 'ns': 2,
                          'pageid': 8110261,
                          'revisions': [ { 'timestamp': '2017-09-28T21:52:49Z',
                                           'user': 'Misaelflorezav'}],
                          'title': 'Usuario:Misaelflorezav/American Vandal'},
                        { 'ns': 0,
                          'pageid': 8110309,
                          'revisions': [ { 'timestamp': '2017-10-20T13:19:28Z',
                                           'user': 'BenjaBot'}],
                          'title': 'End Records'},
                        { 'ns': 0,
                          'pageid': 8110335,
                          'revisions': [ { 'anon': True,
                                           'timestamp': '2018-05-15T21:34:59Z',
                                           'user': '188.86.122.49'}],
                          'title': 'Ned Washington'},
                        { 'ns': 0,
                          'pageid': 8110339,
                          'revisions': [ { 'timestamp': '2018-11-16T12:55:43Z',
                                           'user': 'MetroBot'}],
                          'title': 'Proteína L10 de la unidad ribosómica '
                                   '60S'}]}}

EN->FR

Page History: English Wiki Pages

URL = "https://en.wikipedia.org/w/api.php"

#generate title string with all titles separated with "|"
title_str_fr = ""
for s in sourcetitles_fr[:5]:
    if s == sourcetitles_fr[4]:
        title_str_fr += s
    else:
        title_str_fr += s + "|"
        
#set parameters
        
PARAMS = {
    "action": "query",
    "prop": "revisions",
    "titles": title_str_fr,
    "rvprop": "timestamp|user",
    "rvslots": "main",
    "formatversion": "2",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA_fr = R.json()

#print(DATA)
DATA_fr.keys()
dict_keys(['batchcomplete', 'query'])
#pretty printing page history of 5 Wiki Articles in English

pp.pprint(DATA_fr)
{ 'batchcomplete': True,
  'query': { 'pages': [ { 'ns': 0,
                          'pageid': 1470255,
                          'revisions': [ { 'timestamp': '2019-03-15T08:22:51Z',
                                           'user': 'Citation bot'}],
                          'title': 'Edith Finch Russell'},
                        { 'ns': 0,
                          'pageid': 36469394,
                          'revisions': [ { 'timestamp': '2018-08-31T13:15:47Z',
                                           'user': 'Ser Amantio di Nicolao'}],
                          'title': 'Patricia Russell, Countess Russell'},
                        { 'ns': 0,
                          'pageid': 37860106,
                          'revisions': [ { 'timestamp': '2018-07-10T15:38:41Z',
                                           'user': 'Cydebot'}],
                          'title': 'Katharine Russell, Viscountess Amberley'},
                        { 'ns': 0,
                          'pageid': 40344958,
                          'revisions': [ { 'timestamp': '2018-03-30T18:47:09Z',
                                           'user': 'PrimeBOT'}],
                          'title': 'Paatsaali School'},
                        { 'ns': 0,
                          'pageid': 52567261,
                          'revisions': [ { 'timestamp': '2018-07-21T13:09:53Z',
                                           'user': 'KolbertBot'}],
                          'title': 'Tiyas Military Airbase'}]}}

Page History: Corresponding French Wiki Pages

#similarly for corresponding french pages

import requests

S = requests.Session()

URL = "https://fr.wikipedia.org/w/api.php"

title_str_target_fr = ""
for s in targettitles_fr[:5]:
    if s == targettitles_fr[4]:
        title_str_target_fr += s
    else:
        title_str_target_fr += s + "|"

#setting parameters
        
PARAMS = {
    "action": "query",
    "prop": "revisions",
    "titles": title_str_target_fr,
    "rvprop": "timestamp|user",
    "rvslots": "main",
    "formatversion": "2",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA_fr_target = R.json()

#print(DATA)
DATA_fr_target.keys()
dict_keys(['batchcomplete', 'query'])
#pretty printing page history of 5 Wiki Articles in French

pp.pprint(DATA_fr_target)
{ 'batchcomplete': True,
  'query': { 'pages': [ { 'missing': True,
                          'ns': 0,
                          'title': 'Tiyas Military Airbase'},
                        { 'ns': 0,
                          'pageid': 11627648,
                          'revisions': [ { 'timestamp': '2018-04-11T21:36:33Z',
                                           'user': 'Huster'}],
                          'title': 'Katharine Russell, Viscomtesse Amberley'},
                        { 'ns': 0,
                          'pageid': 11627653,
                          'revisions': [ { 'timestamp': '2019-03-25T22:09:35Z',
                                           'user': 'GrandCelinien'}],
                          'title': 'Edith Finch Russell'},
                        { 'ns': 0,
                          'pageid': 11627670,
                          'revisions': [ { 'timestamp': '2018-04-14T07:48:04Z',
                                           'user': 'DickensBot'}],
                          'title': 'Paatsaali School'},
                        { 'ns': 0,
                          'pageid': 11627671,
                          'revisions': [ { 'timestamp': '2018-04-11T21:46:16Z',
                                           'user': 'Huster'}],
                          'title': 'Patricia Russell, comtesse Russell'}]}}