Skip to content

How to add new metrics

Abel Serrano Juste edited this page Apr 9, 2018 · 3 revisions

Here are the steps for adding a new metric to WikiChron.

First, you need to define a function —likely in the stats.py file— that computes the metric value. This function has to have two arguments: (data, index) and it has to return a Pandas Time Series.

  • data is all the edition history data (except for the bots activity) of the wiki formatted as a pandas dataframe.
  • index is an index with all the months between the date of creation of the wiki and the last date of the dump, in a pandas DatetimeIndex format. Use it as a base index to reindex your data in order to not accidentally delete dates with empty data when you are grouping data or so.
Then, you need to create an instance of the Metric class and append it to the returning list in generate_metrics() inside metrics_generator.py file. If your metric isn't in stats.py file, make sure that your metric functions is imported in metrics_generator.py.

Finally, if your new metric is in a new category, or in other words, if you have created another category along your new metric, you'll need to add it to the metric_names list in side_bar.py.