Bot-vs-bot reverts

Getting and processing data


In [1]:
# bot-vs-bot revert table: https://quarry.wmflabs.org/query/17237

!wget https://quarry.wmflabs.org/run/161195/output/0/tsv?download=true -O enwiki-botvbot-pagetitles.tsv


--2017-03-10 21:44:24--  https://quarry.wmflabs.org/run/161195/output/0/tsv?download=true
Resolving quarry.wmflabs.org (quarry.wmflabs.org)... 10.68.21.68
Connecting to quarry.wmflabs.org (quarry.wmflabs.org)|10.68.21.68|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/csv]
Saving to: ‘enwiki-botvbot-pagetitles.tsv’

enwiki-botvbot-page     [               <=>    ]  36.78M  3.61MB/s   in 11s    

2017-03-10 21:44:35 (3.41 MB/s) - ‘enwiki-botvbot-pagetitles.tsv’ saved [38564767]


In [19]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

!pip install ftfy
import ftfy


Collecting ftfy
  Downloading ftfy-5.0.1.tar.gz
Requirement already satisfied: html5lib in /srv/paws/lib/python3.4/site-packages (from ftfy)
Requirement already satisfied: wcwidth in /srv/paws/lib/python3.4/site-packages (from ftfy)
Requirement already satisfied: six in /srv/paws/lib/python3.4/site-packages (from html5lib->ftfy)
Installing collected packages: ftfy
  Running setup.py install for ftfy ... - \ done
Successfully installed ftfy-5.0.1

In [3]:
df = pd.read_csv("enwiki-botvbot-pagetitles.tsv", sep="\t", encoding='utf-8')
len(df)


Out[3]:
158606

In [4]:
print(df.columns)


Index(['rev_id', 'rev_timestamp', 'rev_user', 'rev_user_text', 'rev_page',
       'rev_sha1', 'rev_minor_edit', 'rev_deleted', 'rev_parent_id',
       'archived', 'reverting_id', 'reverting_timestamp', 'reverting_user',
       'reverting_user_text', 'reverting_page', 'reverting_sha1',
       'reverting_minor_edit', 'reverting_deleted', 'reverting_parent_id',
       'reverting_archived', 'rev_revert_offset', 'revisions_reverted',
       'reverted_to_rev_id', 'page_namespace', 'page_title'],
      dtype='object')

In [5]:
df[0:5]


Out[5]:
rev_id rev_timestamp rev_user rev_user_text rev_page rev_sha1 rev_minor_edit rev_deleted rev_parent_id archived ... reverting_sha1 reverting_minor_edit reverting_deleted reverting_parent_id reverting_archived rev_revert_offset revisions_reverted reverted_to_rev_id page_namespace page_title
0 56161718 20060531172522 91310 CanisRufus 584516 1lyohbi8ymubjfzdb4w4ssfiflfpgat 1 0 54170358 0 ... b3lf3olmh1hw99f68tjh187jl7dzi1j 1 0 56161718 0 1 1 54170358 0 Sharon_Pratt_Kelly
1 56161633 20060531172452 91310 CanisRufus 793703 bxfv9z3d7uypsla28qfioc5qs4l963w 1 0 54169562 0 ... 1nlk1pfhntoa3m0inrdpotrqb5ajxif 1 0 56161633 0 1 1 54169562 0 Anthony_A._Williams
2 103117636 20070125105128 234358 Mathbot 5202035 6ruzx0gegy5xy0mw5yxsdnh1fir7mwd 0 0 102641383 0 ... c6uu9wkg34ko0nidqakdktfkkvcds3k 0 0 104315087 0 1 3 102641383 4 Version_1.0_Editorial_Team/Core_topics_article...
3 105582355 20070204154028 234358 Mathbot 6744678 p14vq3lzxeu50upo1ax9h3ya2hrz1hv 0 0 104618440 0 ... qaiydx752b8av3qp2zbnfpqspttpw91 0 0 105582355 0 1 1 104618440 4 Version_1.0_Editorial_Team/Medicine_articles_b...
4 105627219 20070204194135 234358 Mathbot 8468041 rebsad1ch2hvs85nhf0nwm2r8ukboil 0 0 104982162 0 ... 3lda2892o6z3p29r8xipbqh780h2rph 0 0 105627219 0 1 1 104982162 4 Version_1.0_Editorial_Team/Soft_drinks_article...

5 rows × 25 columns


In [6]:
df['reverting_timestamp_dt'] = pd.to_datetime(df['reverting_timestamp'], format="%Y%m%d%H%M%S")

In [7]:
df = df.set_index('reverting_timestamp_dt')

In [8]:
#df = df[df['page_namespace'] == 0].copy()

In [21]:
df['usertext_pair'] = df['reverting_user_text'] + " reverting " + df['rev_user_text']
df['usertext_pair'].value_counts().head()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-427b3df18e94> in <module>()
----> 1 df['usertext_pair'] = ftfy.fix_text(df['reverting_user_text']) + " reverting " + ftfy.fix_text(df['rev_user_text'])
      2 df['usertext_pair'].value_counts().head()

/srv/paws/lib/python3.4/site-packages/ftfy/__init__.py in fix_text(text, fix_entities, remove_terminal_escapes, fix_encoding, fix_latin_ligatures, fix_character_width, uncurl_quotes, fix_line_breaks, fix_surrogates, remove_control_chars, remove_bom, normalization, max_decode_length)
    153     pos = 0
    154     while pos < len(text):
--> 155         textbreak = text.find('\n', pos) + 1
    156         fix_encoding_this_time = fix_encoding
    157         if textbreak == 0:

/srv/paws/lib/python3.4/site-packages/pandas/core/generic.py in __getattr__(self, name)
   2742             if name in self._info_axis:
   2743                 return self[name]
-> 2744             return object.__getattribute__(self, name)
   2745 
   2746     def __setattr__(self, name, value):

AttributeError: 'Series' object has no attribute 'find'

In [10]:
df['usertext_pair'].values


Out[10]:
array(['Cydebot reverting CanisRufus', 'Cydebot reverting CanisRufus',
       'WP 1.0 bot reverting Mathbot', ...,
       'Citation bot reverting Citation bot 2',
       'AvicBot reverting EmausBot', 'DumbBOT reverting Lowercase sigmabot'], dtype=object)

In [11]:
gp = df.groupby(['usertext_pair'])

In [12]:
df['page_namespace'].value_counts()


Out[12]:
0      83295
4      31227
14     27417
1      10354
3       3365
2       1350
10       890
5        253
11       204
6        177
109       28
100       27
7          5
108        4
101        3
118        3
12         2
15         2
Name: page_namespace, dtype: int64

In [13]:
def botpair_ns_table(botpair_df):
    tablestr = "Reverts by namespace<br>\n"
    for x, y in botpair_df.page_namespace.value_counts().iteritems():
        namespaces_dict={0: "Article:", 
                         1: "Talk:",
                         2:"User:",
                         3: "User_talk:",
                         4:"Wikipedia:",
                         5: "Wikipedia_talk:",
                         6:"File:",
                         7:"File_talk:",
                         8:"MediaWiki:",
                         9:"MediaWiki_talk:",
                         10:"Template:", 
                         11:"Template_talk:",
                         12:"Help:",
                         13:"Help_talk:",
                         14:"Category:", 
                         15:"Category_talk:",
                         100:"Portal:",
                         101:"Portal_talk:",
                         108:"Book:",
                         109:"Book_talk:",
                         118:"Draft:"}
    
        tablestr = tablestr + namespaces_dict[x] + " " + str(y) + "<br>\n"
    return tablestr

In [14]:
namespaces_dict={0: "", 
                 1: "Talk:",
                 2:"User:",
                 3: "User_talk:",
                 4:"Wikipedia:",
                 5: "Wikipedia_talk:",
                 6:"File:",
                 7:"File_talk:",
                 8:"MediaWiki:",
                 9:"MediaWiki_talk:",
                 10:"Template:", 
                 11:"Template_talk:",
                 12:"Help:",
                 13:"Help_talk:",
                 14:"Category:", 
                 15:"Category_talk:",
                 100:"Portal:",
                 101:"Portal_talk:",
                 108:"Book:",
                 109:"Book_talk:",
                 118:"Draft:"}

In [20]:
with open("botvbot.html", "w") as f:
    f.write("<h1>Bot vs bot reverts on enwiki</h1>")
    f.write("<p>For bot-bot pairs with more than 20 reverts</p>")
    f.write("<p>Jupyter notebook for this code <a href=\"http://paws-public.wmflabs.org/paws-public/User:Staeiou/wiki-stat-notebooks/botvbot/exploratory-botplots-samples.ipynb#\"> here</a></p>")
    for botpair in df['usertext_pair'].unique():
        botpair_df = df[df['usertext_pair'] == botpair]
        total_reverts = len(botpair_df)
        if total_reverts > 20:
            
            first_revert = df[df['usertext_pair'] == botpair].index.min()
            last_revert = df[df['usertext_pair'] == botpair].index.max()
            sample = df[df['usertext_pair'] == botpair].sample(2)    
            count = 0
            f.write("<h2>" + ftfy.fix_text(botpair) + "</h2>\n")
            f.write("<p>Total reverts: " + str(total_reverts) + "</p>\n")
            f.write(botpair_ns_table(botpair_df))
            f.write("<p>First revert: " + str(first_revert) + "</p>\n")
            f.write("<p>Last revert: " + str(last_revert) + "</p>\n")
            f.write("<p>Random examples: ")
                        
            for revid in df[df['usertext_pair'] == botpair].sample(20).iterrows():
                page_title = namespaces_dict[revid[1].page_namespace] + revid[1].page_title
                
                f.write("<a href=\"https://en.wikipedia.org/w/index.php?title=" + page_title + "&diff=prev&oldid=" + str(revid[1].reverting_id) + "\">" + str(count) + "</a> ")
                count = count + 1

In [49]:
output_df = pd.DataFrame(columns=["reverting_bot", "reverted_bot", "total_reverts", "ns0_reverts", "ex0", "ex1", "ex2", "ex3", "ex4", "ex5", "ex6", "ex7", "ex8", "ex9", "ex10"])

with open("botvbot.tsv", "w") as f:
    for botpair in df['usertext_pair'].unique():
        botpair_df = df[df['usertext_pair'] == botpair]
        total_reverts = len(botpair_df)
        ns0_reverts = len(botpair_df[botpair_df['page_namespace'] == 0])
        if total_reverts > 20:
            sample = df[df['usertext_pair'] == botpair].sample(1)  
            
            reverting_user_text_link = "=HYPERLINK(\"http://enwp.org/User:" + sample.reverting_user_text[0] + "\",\"" + sample.reverting_user_text[0] + "\")"
            rev_user_text_link = "=HYPERLINK(\"http://enwp.org/User:" + sample.rev_user_text[0] + "\",\"" + sample.rev_user_text[0] + "\")"

            first_revert = df[df['usertext_pair'] == botpair].index.min()
            last_revert = df[df['usertext_pair'] == botpair].index.max()

            ex = {}
            count = 0

            for revid in df[df['usertext_pair'] == botpair].sample(10).iterrows():
                page_title = namespaces_dict[revid[1].page_namespace] + revid[1].page_title
                ex[count] = "=HYPERLINK(\"https://en.wikipedia.org/w/index.php?title=" + page_title + "&diff=prev&oldid=" + str(revid[1].reverting_id) + "\",\"diff\")"
                
                count = count + 1
                
            output_df = output_df.append({"reverting_bot":reverting_user_text_link,
                                          "reverted_bot":rev_user_text_link,
                                          "total_reverts": total_reverts,
                                          "ns0_reverts":ns0_reverts,
                                          "ex0":ex{0},
                                          "ex1":ex{1},
                                          "ex2":ex{2},
                                          "ex3":ex{3},
                                          "ex4":ex{4},
                                          "ex5":ex{5},
                                          "ex6":ex{6},
                                          "ex7":ex{7},
                                          "ex8":ex{8},
                                          "ex9":ex{9}},
                                         ignore_index=True)


  File "<ipython-input-49-69398291b023>", line 30
    "ex0":ex{0},
            ^
SyntaxError: invalid syntax

In [41]:
output_df


Out[41]:
reverting_bot reverted_bot total_reverts ns0_reverts examples
0 <a href="http://enwp.org/User:FrescoBot">Fresc... <a href="http://enwp.org/User:Mathbot">Mathbot... 58.0 58.0 <a href="https://en.wikipedia.org/w/index.php?...
1 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:Chobot">Chobot</a> 1825.0 154.0 <a href="https://en.wikipedia.org/w/index.php?...
2 <a href="http://enwp.org/User:Xqbot">Xqbot</a> <a href="http://enwp.org/User:Chobot">Chobot</a> 34.0 34.0 <a href="https://en.wikipedia.org/w/index.php?...
3 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:Chobot">Chobot</a> 294.0 92.0 <a href="https://en.wikipedia.org/w/index.php?...
4 <a href="http://enwp.org/User:KLBot2">KLBot2</a> <a href="http://enwp.org/User:Chobot">Chobot</a> 172.0 7.0 <a href="https://en.wikipedia.org/w/index.php?...
5 <a href="http://enwp.org/User:タチコマ robot">タチコマ... <a href="http://enwp.org/User:RussBot">RussBot... 2056.0 1981.0 <a href="https://en.wikipedia.org/w/index.php?...
6 <a href="http://enwp.org/User:Cydebot">Cydebot... <a href="http://enwp.org/User:RussBot">RussBot... 964.0 882.0 <a href="https://en.wikipedia.org/w/index.php?...
7 <a href="http://enwp.org/User:BOTijo">BOTijo</a> <a href="http://enwp.org/User:RussBot">RussBot... 31.0 31.0 <a href="https://en.wikipedia.org/w/index.php?...
8 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:RussBot">RussBot... 402.0 396.0 <a href="https://en.wikipedia.org/w/index.php?...
9 <a href="http://enwp.org/User:Xqbot">Xqbot</a> <a href="http://enwp.org/User:RussBot">RussBot... 5163.0 4689.0 <a href="https://en.wikipedia.org/w/index.php?...
10 <a href="http://enwp.org/User:Thehelpfulbot">T... <a href="http://enwp.org/User:RussBot">RussBot... 55.0 18.0 <a href="https://en.wikipedia.org/w/index.php?...
11 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:RussBot">RussBot... 878.0 836.0 <a href="https://en.wikipedia.org/w/index.php?...
12 <a href="http://enwp.org/User:AvicBot">AvicBot... <a href="http://enwp.org/User:RussBot">RussBot... 1789.0 1528.0 <a href="https://en.wikipedia.org/w/index.php?...
13 <a href="http://enwp.org/User:ArmbrustBot">Arm... <a href="http://enwp.org/User:RussBot">RussBot... 24.0 8.0 <a href="https://en.wikipedia.org/w/index.php?...
14 <a href="http://enwp.org/User:RussBot">RussBot... <a href="http://enwp.org/User:タチコマ robot">タチコマ... 1354.0 1232.0 <a href="https://en.wikipedia.org/w/index.php?...
15 <a href="http://enwp.org/User:BOTijo">BOTijo</a> <a href="http://enwp.org/User:タチコマ robot">タチコマ... 21.0 21.0 <a href="https://en.wikipedia.org/w/index.php?...
16 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:タチコマ robot">タチコマ... 34.0 33.0 <a href="https://en.wikipedia.org/w/index.php?...
17 <a href="http://enwp.org/User:Xqbot">Xqbot</a> <a href="http://enwp.org/User:タチコマ robot">タチコマ... 1076.0 999.0 <a href="https://en.wikipedia.org/w/index.php?...
18 <a href="http://enwp.org/User:Thehelpfulbot">T... <a href="http://enwp.org/User:タチコマ robot">タチコマ... 31.0 26.0 <a href="https://en.wikipedia.org/w/index.php?...
19 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:タチコマ robot">タチコマ... 223.0 211.0 <a href="https://en.wikipedia.org/w/index.php?...
20 <a href="http://enwp.org/User:AvicBot">AvicBot... <a href="http://enwp.org/User:タチコマ robot">タチコマ... 528.0 463.0 <a href="https://en.wikipedia.org/w/index.php?...
21 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:SuggestBot">Sugg... 296.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
22 <a href="http://enwp.org/User:Lowercase sigmab... <a href="http://enwp.org/User:SuggestBot">Sugg... 38.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
23 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:MiszaBot">MiszaB... 68.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
24 <a href="http://enwp.org/User:RussBot">RussBot... <a href="http://enwp.org/User:Cydebot">Cydebot... 1174.0 969.0 <a href="https://en.wikipedia.org/w/index.php?...
25 <a href="http://enwp.org/User:ArmbrustBot">Arm... <a href="http://enwp.org/User:Cydebot">Cydebot... 86.0 45.0 <a href="https://en.wikipedia.org/w/index.php?...
26 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:JAnDbot">JAnDbot... 165.0 59.0 <a href="https://en.wikipedia.org/w/index.php?...
27 <a href="http://enwp.org/User:Xqbot">Xqbot</a> <a href="http://enwp.org/User:JAnDbot">JAnDbot... 35.0 32.0 <a href="https://en.wikipedia.org/w/index.php?...
28 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:JAnDbot">JAnDbot... 63.0 30.0 <a href="https://en.wikipedia.org/w/index.php?...
29 <a href="http://enwp.org/User:KLBot2">KLBot2</a> <a href="http://enwp.org/User:JAnDbot">JAnDbot... 24.0 5.0 <a href="https://en.wikipedia.org/w/index.php?...
... ... ... ... ... ...
142 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:DPL bot">DPL bot... 160.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
143 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:DPL bot">DPL bot... 159.0 159.0 <a href="https://en.wikipedia.org/w/index.php?...
144 <a href="http://enwp.org/User:Lowercase sigmab... <a href="http://enwp.org/User:DPL bot">DPL bot... 57.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
145 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:BattyBot">BattyB... 22.0 22.0 <a href="https://en.wikipedia.org/w/index.php?...
146 <a href="http://enwp.org/User:Chobot">Chobot</a> <a href="http://enwp.org/User:DarafshBot">Dara... 53.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
147 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:DarafshBot">Dara... 825.0 467.0 <a href="https://en.wikipedia.org/w/index.php?...
148 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:DarafshBot">Dara... 207.0 42.0 <a href="https://en.wikipedia.org/w/index.php?...
149 <a href="http://enwp.org/User:KLBot2">KLBot2</a> <a href="http://enwp.org/User:DarafshBot">Dara... 69.0 2.0 <a href="https://en.wikipedia.org/w/index.php?...
150 <a href="http://enwp.org/User:Hazard-Bot">Haza... <a href="http://enwp.org/User:Cyberbot I">Cybe... 71.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
151 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:Cyberbot II">Cyb... 31.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
152 <a href="http://enwp.org/User:Amalthea (bot)">... <a href="http://enwp.org/User:Cyberbot II">Cyb... 779.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
153 <a href="http://enwp.org/User:Hazard-Bot">Haza... <a href="http://enwp.org/User:Lowercase sigmab... 28.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
154 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:Dexbot">Dexbot</a> 692.0 195.0 <a href="https://en.wikipedia.org/w/index.php?...
155 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:Dexbot">Dexbot</a> 141.0 7.0 <a href="https://en.wikipedia.org/w/index.php?...
156 <a href="http://enwp.org/User:KLBot2">KLBot2</a> <a href="http://enwp.org/User:Dexbot">Dexbot</a> 83.0 2.0 <a href="https://en.wikipedia.org/w/index.php?...
157 <a href="http://enwp.org/User:Chobot">Chobot</a> <a href="http://enwp.org/User:Makecat-bot">Mak... 248.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
158 <a href="http://enwp.org/User:Addbot">Addbot</a> <a href="http://enwp.org/User:Makecat-bot">Mak... 5260.0 3417.0 <a href="https://en.wikipedia.org/w/index.php?...
159 <a href="http://enwp.org/User:Xqbot">Xqbot</a> <a href="http://enwp.org/User:Makecat-bot">Mak... 31.0 30.0 <a href="https://en.wikipedia.org/w/index.php?...
160 <a href="http://enwp.org/User:EmausBot">EmausB... <a href="http://enwp.org/User:Makecat-bot">Mak... 1761.0 595.0 <a href="https://en.wikipedia.org/w/index.php?...
161 <a href="http://enwp.org/User:KLBot2">KLBot2</a> <a href="http://enwp.org/User:Makecat-bot">Mak... 452.0 195.0 <a href="https://en.wikipedia.org/w/index.php?...
162 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:Theo's Little Bo... 136.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
163 <a href="http://enwp.org/User:Lowercase sigmab... <a href="http://enwp.org/User:Theo's Little Bo... 41.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
164 <a href="http://enwp.org/User:タチコマ robot">タチコマ... <a href="http://enwp.org/User:VoxelBot">VoxelB... 111.0 111.0 <a href="https://en.wikipedia.org/w/index.php?...
165 <a href="http://enwp.org/User:AvicBot">AvicBot... <a href="http://enwp.org/User:VoxelBot">VoxelB... 27.0 27.0 <a href="https://en.wikipedia.org/w/index.php?...
166 <a href="http://enwp.org/User:RussBot">RussBot... <a href="http://enwp.org/User:ArmbrustBot">Arm... 28.0 10.0 <a href="https://en.wikipedia.org/w/index.php?...
167 <a href="http://enwp.org/User:Cydebot">Cydebot... <a href="http://enwp.org/User:ArmbrustBot">Arm... 318.0 317.0 <a href="https://en.wikipedia.org/w/index.php?...
168 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:BracketBot">Brac... 31.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
169 <a href="http://enwp.org/User:Lowercase sigmab... <a href="http://enwp.org/User:BracketBot">Brac... 31.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
170 <a href="http://enwp.org/User:ClueBot III">Clu... <a href="http://enwp.org/User:MediaWiki messag... 312.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...
171 <a href="http://enwp.org/User:Lowercase sigmab... <a href="http://enwp.org/User:MediaWiki messag... 458.0 0.0 <a href="https://en.wikipedia.org/w/index.php?...

172 rows × 5 columns


In [46]:
!pip install openpyxl
output_df.to_csv("revert_by_botpair.tsv", sep="\t")
output_df.to_excel("revert_by_botpair.xlsx")


Collecting openpyxl
  Downloading openpyxl-2.4.5.tar.gz (180kB)
    100% |████████████████████████████████| 184kB 382kB/s eta 0:00:01
Collecting jdcal (from openpyxl)
  Using cached jdcal-1.3.tar.gz
Collecting et_xmlfile (from openpyxl)
  Using cached et_xmlfile-1.0.1.tar.gz
Installing collected packages: jdcal, et-xmlfile, openpyxl
  Running setup.py install for jdcal ... - done
  Running setup.py install for et-xmlfile ... - done
  Running setup.py install for openpyxl ... - \ | / - done
Successfully installed et-xmlfile-1.0.1 jdcal-1.3 openpyxl-2.4.5

In [43]:
!head revert_by_botpair.tsv


	reverting_bot	reverted_bot	total_reverts	ns0_reverts	examples
0	"<a href=""http://enwp.org/User:FrescoBot"">FrescoBot</a>"	"<a href=""http://enwp.org/User:Mathbot"">Mathbot</a>"	58.0	58.0	"<a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(Y)&diff=prev&oldid=506645953"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(X)&diff=prev&oldid=518230338"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(O)&diff=prev&oldid=487636640"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(Z)&diff=prev&oldid=502248903"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(O)&diff=prev&oldid=371875375"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(J)&diff=prev&oldid=381630028"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(X)&diff=prev&oldid=421732463"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(X)&diff=prev&oldid=466698834"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(Y)&diff=prev&oldid=392268041"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_mathematicians_(X)&diff=prev&oldid=438590202"">9</a> "
1	"<a href=""http://enwp.org/User:Addbot"">Addbot</a>"	"<a href=""http://enwp.org/User:Chobot"">Chobot</a>"	1825.0	154.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Category:Organisations_based_in_the_Bahamas&diff=prev&oldid=545958908"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:21st_century_in_Liechtenstein&diff=prev&oldid=545324893"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Poland–Soviet_Union_border&diff=prev&oldid=550622093"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Environment_of_Guinea-Bissau&diff=prev&oldid=544784738"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Christianity_in_Tajikistan&diff=prev&oldid=546620500"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Borders_of_Jamaica&diff=prev&oldid=545743837"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Astronomical_objects_discovered_in_1864&diff=prev&oldid=547208335"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=Jiyūgaoka_Station&diff=prev&oldid=544619355"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Geology_of_Cambodia&diff=prev&oldid=546099607"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Namibia_at_the_Paralympics&diff=prev&oldid=545422338"">9</a> "
2	"<a href=""http://enwp.org/User:Xqbot"">Xqbot</a>"	"<a href=""http://enwp.org/User:Chobot"">Chobot</a>"	34.0	34.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Three_Hundred_and_Thirty_Five_Years'_War&diff=prev&oldid=350497332"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Karuizawa_Station&diff=prev&oldid=405576508"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Swimming_at_the_1896_Summer_Olympics_–_Men's_100_metre_freestyle&diff=prev&oldid=354420814"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Swimming_at_the_1896_Summer_Olympics_–_Men's_500_metre_freestyle&diff=prev&oldid=354420898"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=Time_Travel_Tondekeman&diff=prev&oldid=316674601"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Quran&diff=prev&oldid=498608549"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=Mary,_Crown_Princess_of_Denmark&diff=prev&oldid=407345090"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=Marineland_of_Canada&diff=prev&oldid=355224923"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=2._Bundesliga&diff=prev&oldid=433774278"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Karuizawa_Station&diff=prev&oldid=406764007"">9</a> "
3	"<a href=""http://enwp.org/User:EmausBot"">EmausBot</a>"	"<a href=""http://enwp.org/User:Chobot"">Chobot</a>"	294.0	92.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Category:634_BC&diff=prev&oldid=611546165"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Daegok–Sosa_Line&diff=prev&oldid=534670464"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Water_in_Afghanistan&diff=prev&oldid=548709373"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Water_in_Uzbekistan&diff=prev&oldid=548700609"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=Hayato_Station&diff=prev&oldid=550856607"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Spanish_human_rights_activists&diff=prev&oldid=547955763"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Astronomical_objects_discovered_in_1869&diff=prev&oldid=548109112"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Tretorn_SERIE+_tournaments&diff=prev&oldid=555672526"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=Tatsuya_Fujiwara&diff=prev&oldid=508705489"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Sanya&diff=prev&oldid=547847428"">9</a> "
4	"<a href=""http://enwp.org/User:KLBot2"">KLBot2</a>"	"<a href=""http://enwp.org/User:Chobot"">Chobot</a>"	172.0	7.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Category:Natural_history_of_Singapore&diff=prev&oldid=547606748"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1653_in_Asia&diff=prev&oldid=546562741"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Yonsei_University_alumni&diff=prev&oldid=546137705"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1140s_books&diff=prev&oldid=546532264"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1455_works&diff=prev&oldid=546546036"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1677_in_Asia&diff=prev&oldid=546565406"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1660_in_Asia&diff=prev&oldid=546563841"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1673_works&diff=prev&oldid=546312676"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1457_works&diff=prev&oldid=546545936"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:1478_works&diff=prev&oldid=546438907"">9</a> "
5	"<a href=""http://enwp.org/User:タチコマ robot"">タチコマ robot</a>"	"<a href=""http://enwp.org/User:RussBot"">RussBot</a>"	2056.0	1981.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Talk:Malaysia_national_under-19_football_team&diff=prev&oldid=185383377"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Dennou_Senshi_Porygon&diff=prev&oldid=219039049"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Arabic_world&diff=prev&oldid=202289083"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Aston-Martin_Vanquish&diff=prev&oldid=221049086"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=Largest_soverign_wealth_funds&diff=prev&oldid=202563119"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=No_Pain,_No_Game&diff=prev&oldid=196491428"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=Asher_Ginzberg&diff=prev&oldid=193880532"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=JJ_Williams&diff=prev&oldid=198584845"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=Pagoda_in_Myanmar&diff=prev&oldid=184002143"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Goryo_Dynasty&diff=prev&oldid=171888911"">9</a> "
6	"<a href=""http://enwp.org/User:Cydebot"">Cydebot</a>"	"<a href=""http://enwp.org/User:RussBot"">RussBot</a>"	964.0	882.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Syndicate_(video_game)&diff=prev&oldid=310873039"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Bruce_Ferguson&diff=prev&oldid=235987093"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=9694_Lycomedes&diff=prev&oldid=599852920"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=1583_Antilochus&diff=prev&oldid=599852773"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=Ramiro_III_of_León&diff=prev&oldid=283742949"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Category:Deceased_people&diff=prev&oldid=321402873"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=The_Legend_of_the_Mystical_Ninja&diff=prev&oldid=310878115"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=12444_Prothoon&diff=prev&oldid=599852597"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=Strike_(series)&diff=prev&oldid=310872987"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=California_Habeas_Project&diff=prev&oldid=186146704"">9</a> "
7	"<a href=""http://enwp.org/User:BOTijo"">BOTijo</a>"	"<a href=""http://enwp.org/User:RussBot"">RussBot</a>"	31.0	31.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Chewbacca_Defense&diff=prev&oldid=274373367"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=Dangerously_in_love&diff=prev&oldid=257993484"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Hamlet_on_Screen&diff=prev&oldid=262475862"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Koryo-Saram&diff=prev&oldid=307121284"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=List_of_Disney_Feature_Films&diff=prev&oldid=175453295"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Ray_Tracing&diff=prev&oldid=232634948"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=Soham_Murders&diff=prev&oldid=258950491"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=Tamil_Cinema&diff=prev&oldid=284962809"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=DiC_Entertainment&diff=prev&oldid=261629909"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Assyrian_Independence&diff=prev&oldid=257193986"">9</a> "
8	"<a href=""http://enwp.org/User:Addbot"">Addbot</a>"	"<a href=""http://enwp.org/User:RussBot"">RussBot</a>"	402.0	396.0	"<a href=""https://en.wikipedia.org/w/index.php?title=Petrolul_Bucureşti&diff=prev&oldid=257676877"">0</a> <a href=""https://en.wikipedia.org/w/index.php?title=India-Pakistan_Relations&diff=prev&oldid=256404966"">1</a> <a href=""https://en.wikipedia.org/w/index.php?title=Cat_colony&diff=prev&oldid=256402469"">2</a> <a href=""https://en.wikipedia.org/w/index.php?title=Beheshti&diff=prev&oldid=253367228"">3</a> <a href=""https://en.wikipedia.org/w/index.php?title=ABKB&diff=prev&oldid=255815458"">4</a> <a href=""https://en.wikipedia.org/w/index.php?title=Ruby_(character)&diff=prev&oldid=261866105"">5</a> <a href=""https://en.wikipedia.org/w/index.php?title=ATI_technologies&diff=prev&oldid=261866067"">6</a> <a href=""https://en.wikipedia.org/w/index.php?title=Onyx_(hip_hop)&diff=prev&oldid=261875012"">7</a> <a href=""https://en.wikipedia.org/w/index.php?title=Newport_High_Street_station&diff=prev&oldid=257683000"">8</a> <a href=""https://en.wikipedia.org/w/index.php?title=Hiderabad&diff=prev&oldid=255826376"">9</a> "

In [ ]: