<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Bot-vs-bot reverts
Getting and processing data
Step1:  Total reverts by namespace
Step2:  Group by reverter and namespace
Step3:  Botplots
Daily reverts subplotted by reverting bot, linear y-axis, not shared y-axis
Step4:  Daily reverts subplotted by reverting bot, linear y-axis, shared y-axis
<ASSISTANT_TASK:>
Python Code:
# bot-vs-bot revert table: https://quarry.wmflabs.org/query/17237
!wget https://quarry.wmflabs.org/run/161084/output/0/tsv?download=true -O botvbot.tsv
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv("botvbot.tsv", sep="\t")
len(df)
print(df.columns)
df[0:5]
df['reverting_timestamp_dt'] = pd.to_datetime(df['reverting_timestamp'], format="%Y%m%d%H%M%S")
df = df.set_index('reverting_timestamp_dt')
Explanation: Bot-vs-bot reverts
Getting and processing data
End of explanation
df.page_namespace.value_counts()
Explanation: Total reverts by namespace
End of explanation
df.reverting_user_text.value_counts()
len(df.reverting_user_text.value_counts())
topbots = df.reverting_user_text.value_counts().index.tolist()[0:24]
topbots
gp3 = df.groupby([pd.TimeGrouper('1D', closed='left'), 'reverting_user_text'])
user_namespace_g = gp3.rev_id.count()
user_namespace_g.head()
user_namespace_g.unstack().head()
user_namespace_unstack = user_namespace_g.unstack()[topbots]
Explanation: Group by reverter and namespace
End of explanation
fig, axes = plt.subplots(ncols=1,nrows=len(topbots), figsize=[14,28], sharex=True)
user_namespace_unstack[topbots].plot(subplots=True, kind='area', ax=axes)
fig.subplots_adjust(hspace=.25)
Explanation: Botplots
Daily reverts subplotted by reverting bot, linear y-axis, not shared y-axis
End of explanation
fig, axes = plt.subplots(ncols=1,nrows=len(topbots), figsize=[14,28], sharex=True, sharey=True)
user_namespace_unstack[topbots].plot(subplots=True, kind='area', ax=axes)
fig.subplots_adjust(hspace=.25)
user_namespace_unstack['Addbot'].plot(kind='area')
user_namespace_unstack['AvicBot'].plot(kind='area')
user_namespace_unstack['Xqbot'].plot(kind='area')
user_namespace_unstack['KLBot2'].plot(kind='area')
user_namespace_unstack['RussBot'].plot(kind='area')
Explanation: Daily reverts subplotted by reverting bot, linear y-axis, shared y-axis
End of explanation
<END_TASK>