The WikiWho class also provides the dv
attribute (DataView
class), which returns the data in pandas dataFrames.
from wikiwho_wrapper import WikiWho
ww = WikiWho(lng='en')
The DataView has exactly the same functions (and parameters) as the WikiWhoAPI and they are mapped one to one:
all_content()
rev_ids_of_article()
last_rev_content()
specific_rev_content_by_rev_id()
range_rev_content_by_article_title()
This is how you use them.
# by article title
df = ww.dv.all_content(
article='Bioglass 45S5')
# or, by article id
# ww.dv.all_content(2161298)
df.head(3)
# by article title
df = ww.dv.rev_ids_of_article(
article='Bioglass 45S5')
# or, by article id
# ww.dv.rev_ids_of_article(2161298)
df.head(3)
# by article title
df = ww.dv.last_rev_content(
article='Bioglass 45S5')
# or, by article id
# ww.dv.last_rev_content(2161298)
df.head(5)
# by revision id directly
df = ww.dv.specific_rev_content_by_rev_id(
rev_id=189370281)
# or by also specifying the article_title (it is not documented in Wikipedia that revisions ids are unique
# and don't depend on the article)
# df = ww.dv.specific_rev_content_by_rev_id(article='bioglass', rev_id=189370281)
df.head(3)
# providing a range (two revision ids)
df = ww.dv.range_rev_content_by_article_title(
article='Bioglass 45S5', start_rev_id=18064039, end_rev_id=207995408)
df.head(3)
# by page id
df = ww.dv.edit_persistence(page_id=2161298)
df.head(3)
# by editor id
df = ww.dv.edit_persistence(editor_id=101935)
df.head(3)
# by page id and editor id
df = ww.dv.edit_persistence(page_id=15745, editor_id=101935)
df.head(3)
You just learn how to use the functions of the APIWrapper. The next tutorial will show simple examples how to extract some information of the all_content()
function
from utils.notebooks import get_next_notebook
from IPython.display import HTML
try:
display(HTML(f'<a href="{get_next_notebook()}" target="_blank">Go to next workbook</a>'))
except:
HTML('<a href="3. History of tokens (all_content).ipynb" target="_blank">Go to next workbook</a>')