Classes

This chapter documents the classes used.

CallofDuty

CallofDuty(hacker_data, squad_data, streamer_mode):

Calculate stats for all maps/modes for each squad member.

Parameters
  • user_input_dict (dict) – A dict of user inputs.

  • squad_data (bool) – If True, will build the Squad class. default is True. Optional

  • hacker_data (bool) – This Requires a seperate csv with hacker data saved. This data can be collected by finding hackers after the fact and scraping there data from CodTracker, this can then be used to find hackers in other games. Default is False. Optional

  • streamer_mode (bool) – If True, will hide User inputted Gamertag’s and Uno’s. default is False. Optional

Example
>>> from warzone.call_of_duty import CallofDuty
    >>> inputs = {'repo': 'local data directory',
    >>>        'gamertag': 'your gamertag',
    >>>        'squad': ['friend gamertag1', 'friend gamertag2', '... etc'],
    >>>        'file_name': 'match_data.csv'}
    >>> cod = CallofDuty(user_input_dict=inputs, squad_data=True, hacker_data=False, streamer_mode=False)
        >>> from call_of_duty import CallofDuty
>>> inputs = {'repo': 'local data directory',
>>>        'gamertag': 'your gamertag',
>>>        'squad': ['friend gamertag1', 'friend gamertag2', '... etc'],
>>>        'file_name': 'match_data.csv'}
>>> cod = CallofDuty(user_input_dict=inputs, squad_data=True, hacker_data=False, streamer_mode=False)
Note

This will calculate and build the CallofDuty class.

DocumentFilter

DocumentFilter class objects.

DocumentFilter(hacker_data, squad_data, streamer_mode):

Get a selection from a DataFrame. Uses a set of filters to return a desired set of data to be used in later analysis.

Parameters
  • original_df (pd.DataFrame) – Input DataFrame to be filtered.

  • map_choice (str) – Map filter. Either ‘mp_e’ for Rebirth and ‘mp_d’ for Verdansk. Optional

  • mode_choice (str) – Mode filter. Either ‘solo’, ‘duo’, ‘trio’, or ‘quad’. Optional

  • username (str) – Filter by a players username. Can cause errors if same username as another player. Optional

  • uno (str) – Filter by a players uno. Optional

  • username_dic (dict) – Required if ‘username’ or ‘username_lst’ is used. {username1: uno1, username2: uno2, etc}. Optional

  • username_lst (List[str]) – Filter using a list of usernames. Optional

Example
>>> from warzone.document_filter import DocumentFilter
    >>> doc = DocumentFilter(original_df=cod.our_df, map_choice='mp_e', mode_choice='quad')
        >>> from document_filter import DocumentFilter
>>> doc = DocumentFilter(original_df=cod.our_df, map_choice='mp_e', mode_choice='quad')
Note

All inputs, except original_df, are Optional amd defaults are set to None. This will return any data with map = rebirth and mode = Quads. By specifiying ‘cod.our_df’, this will only return data related to the user.

Plot

Plot class objects.

font size = [‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’]

Legend location = [‘best’, ‘upper right’, ‘upper left’, ‘lower left’, ‘lower right’, ‘right’, ‘center left’, ‘center right’, ‘lower center’, ‘upper center’, ‘center’]

Line:

Class for plotting line plots.

Parameters
  • data (pd.DataFrame,) – Input data.

  • limit (int) – Limit the length of data. Optional

  • label_lst (List[str]) – List of labels to include, if None will include all columns. Optional

  • color_lst (List[str]) – List of colors to graph. Optional

  • normalize_x (List[str]) – List of columns to normalize. Optional

  • running_mean_x (List[str]) – List of columns to calculate running mean. Optional

  • running_mean_value (int) – Value used when calculating running mean, default = 50. Optional

  • cumulative_mean_x (List[str]) – List of columns to calculate cumulative mean. Optional

  • fig_size (tuple) – Figure size, default = (10, 7). Optional

  • ylabel (str) – Y axis label. Optional

  • ylabel_color (str) – Y axis label color, default = ‘black’. Optional

  • ylabel_size (str) – Y label size, default = ‘medium’. Optional

  • xlabel (str) – X axis label. Optional

  • xlabel_color (str) – X axis label color, default = ‘black’. Optional

  • xlabel_size (str) – X label size, default = ‘medium’. Optional

  • title (str) – Graph title, default = ‘Line Plot’. Optional

  • title_size (str) – Title size, default = ‘xx-large’. Optional

  • grid (bool) – If True will show grid, default = true. Optional

  • grid_alpha (float) – Grid alpha, default = 0.75. Optional

  • grid_dash_sequence (tuple) – Grid dash sequence, default = (3, 3). Optional

  • grid_lineweight (float) – Grid lineweight, default = 0.5. Optional

  • legend_fontsize (str) – Legend fontsize, default = ‘medium’. Optional

  • legend_transparency (float) – Legend transparency, default = 0.75. Optional

  • legend_location (str) – legend location, default = ‘lower right’. Optional

Example

None

Note

None

Scatter:

Class for plotting scatter plots.

Parameters
  • data (pd.DataFrame,) – Input data.

  • limit (int) – Limit the length of data. Optional

  • label_lst (List[str]) – List of labels to include, if None will include all columns. Optional

  • color_lst (List[str]) – List of colors to graph. Optional

  • normalize_x (List[str]) – List of columns to normalize. Optional

  • regression_line (List[str]) – If included, requires a column str or List[str], default = None. Optional

  • regression_line_color (str) – Color of regression line, default = ‘red’. Optional

  • regression_line_lineweight (float) – Regression lineweight, default = 2.0. Optional

  • running_mean_x (List[str]) – List of columns to calculate running mean. Optional

  • running_mean_value (Optional[int] = 50,) – List of columns to calculate running mean. Optional

  • cumulative_mean_x (List[str]) – List of columns to calculate cumulative mean. Optional

  • fig_size (tuple) – default = (10, 7), Optional

  • ylabel (str) – Y axis label. Optional

  • ylabel_color (str) – Y axis label color, default = ‘black’. Optional

  • ylabel_size (str) – Y label size, default = ‘medium’. Optional

  • xlabel (str) – X axis label. Optional

  • xlabel_color (str) – X axis label color, default = ‘black’. Optional

  • xlabel_size (str) – X label size, default = ‘medium’. Optional

  • title (str) – Graph title, default = ‘Scatter Plot’. Optional

  • title_size (str) – Title size, default = ‘xx-large’. Optional

  • grid (bool) – If True will show grid, default = true. Optional

  • grid_alpha (float) – Grid alpha, default = 0.75. Optional

  • grid_dash_sequence (tuple) – Grid dash sequence, default = (3, 3). Optional

  • grid_lineweight (float) – Grid lineweight, default = 0.5. Optional

  • legend_fontsize (str) – Legend fontsize, default = ‘medium’. Optional

  • legend_transparency (float) – Legend transparency, default = 0.75. Optional

  • legend_location (str) – legend location, default = ‘lower right’. Optional

  • compare_two (List[str]) – If given will return a scatter comparing two variables,default is None. Optional

  • y_limit (float) – If given will limit the y axis.

Example

None

Note

None

Histogram:

Class for plotting histograms.

Parameters
  • data (pd.DataFrame,) – Input data.

  • limit (int) – Limit the length of data. Optional

  • label_lst (List[str]) – List of labels to include, if None will include all columns. Optional

  • color_lst (List[str]) – List of colors to graph. Optional

  • include_norm (str) – Include norm. If included, requires a column str, default = None. Optional

  • norm_color (str) – Norm color, default = ‘red’. Optional

  • norm_lineweight (float) – Norm lineweight, default = 1.0. Optional

  • norm_ylabel (str) – Norm Y axis label. Optional

  • norm_legend_location (str) – Location of norm legend, default = ‘upper right’. Optional

  • fig_size (tuple) – default = (10, 7), Optional

  • bins (str) – Way of calculating bins, default = ‘sturges’. Optional

  • hist_type (str) – Type of histogram, default = ‘bar’. Optional

  • stacked (bool) – If True, will stack histograms, default = False. Optional

  • ylabel (str) – Y axis label. Optional

  • ylabel_color (str) – Y axis label color, default = ‘black’. Optional

  • ylabel_size (str) – Y label size, default = ‘medium’. Optional

  • ytick_rotation (Optional[int] = 0,) –

  • xlabel (str) – X axis label. Optional

  • xlabel_color (str) – X axis label color, default = ‘black’. Optional

  • xlabel_size (str) – X label size, default = ‘medium’. Optional

  • xtick_rotation (Optional[int] = 0,) –

  • title (str) – Graph title, default = ‘Histogram’. Optional

  • title_size (str) – Title size, default = ‘xx-large’. Optional

  • grid (bool) – If True will show grid, default = true. Optional

  • grid_alpha (float) – Grid alpha, default = 0.75. Optional

  • grid_dash_sequence (tuple) – Grid dash sequence, default = (3, 3). Optional

  • grid_lineweight (float) – Grid lineweight, default = 0.5. Optional

  • legend_fontsize (str) – Legend fontsize, default = ‘medium’. Optional

  • legend_transparency (float) – Legend transparency, default = 0.75. Optional

  • legend_location (str) – legend location, default = ‘lower right’. Optional

Example

None

Note

None

Table:

Class for plotting tables.

Parameters
  • data (pd.DataFrame) – Input data.

  • label_lst (List[str]) – List of labels to include, if None will include all columns. Optional

  • fig_size (tuple) – default = (10, 10), Optional

  • font_size (str) – Font size inside cells, default = ‘medium’. Optional

  • col_widths (float) – Width of columns, default = 0.30. Optional

  • row_colors (str) – Color of rows. Optional

  • header_colors (str) – Header of table color. Optional

  • edge_color (str) – Color of cell edges, default = ‘w’. Optional

  • sequential_cells (bool) – If True will color ever other row. Optional

  • color_map (str) – Color map used in cells, default = ‘Greens’. Optional

Example

None

Note

None

Regression

Regression class object.

Regression:

Calculate a linear regression.

Parameters
  • doc_filter (DocumentFilter) – Input DocumentFilter.

  • x_column (str, or List[str]) – Name of column or columns to be used in regression analysis.

  • y_column (str) – Name of column to be used as y variable in regression.

Example
>>> from warzone.document_filter import DocumentFilter
    >>> from warzone.regression import Regression
    >>> doc = DocumentFilter(original_df=cod.our_df, map_choice='mp_e', mode_choice='quad')
    >>> model = Regression(doc_filter=doc, x_column='kills', y_column='placementPercent')
        >>> from document_filter import DocumentFilter
>>> from regression import Regression
>>> doc = DocumentFilter(original_df=cod.our_df, map_choice='mp_e', mode_choice='quad')
>>> model = Regression(doc_filter=doc, x_column='kills', y_column='placementPercent')
Note

This will return a Regression object with regression result information.

Squad

Squad class objects.

Performance:

The Performance class is used to evaluate a players performance on a given map and mode

Parameters
  • original_df (pd.DataFrame) – Input data.

  • nap_choice – Map filter. Either ‘mp_e’ for Rebirth and ‘mp_d’ for Verdansk.

  • mode_choice (str) – Mode filter. Either ‘solo’, ‘duo’, ‘trio’, or ‘quad’.

  • uno (str) – Input person uno Id.

Example

None

Note

None

Person:

The Person class is used to gather all map/mode stats for a given player

Parameters
  • original_df (pd.DataFrame) – Input data.

  • uno (str) – Input person uno Id.

  • gamertag (str) – Input person’s gamertag.

Example

None

Note

None

Squad:

Calculate stats for all maps/modes for each squad memeber.

Parameters
  • squad_lst (List[str]) – List of gamertags. Include your gamertag in the list.

  • original_df (pd.DataFrame) – Original DataFrame for stats to be calculated from.

  • uno_name_dic (dict) – A dict of all gamertags and respective unos.

Example
>>> from warzone.credentials import user_inputs
        >>> from warzone.user import User
        >>> from warzone.squad import Squad
        >>> _User = User(info=user_inputs)
        >>> _Squad = Squad(squad_lst=_User.squad_lst, original_df=cod.our_df, uno_name_dic=cod.name_uno_dict)
            >>> from credentials import user_inputs
    >>> from warzone.user import User
    >>> from warzone.squad import Squad
    >>> _User = User(info=user_inputs)
    >>> _Squad = Squad(squad_lst=_User.squad_lst, original_df=cod.our_df, uno_name_dic=cod.name_uno_dict)
        >>> from warzone.credentials import user_inputs
    >>> from user import User
    >>> from squad import Squad
    >>> _User = User(info=user_inputs)
    >>> _Squad = Squad(squad_lst=_User.squad_lst, original_df=cod.our_df, uno_name_dic=cod.name_uno_dict)
        >>> from credentials import user_inputs
>>> from user import User
>>> from squad import Squad
>>> _User = User(info=user_inputs)
>>> _Squad = Squad(squad_lst=_User.squad_lst, original_df=cod.our_df, uno_name_dic=cod.name_uno_dict)
Note

This will calculate and return the stats for all squad members.

User

User class objects.

User:

Organizes the Users input data.

Parameters

info (dict) – User input dict.

Example
>>> from warzone.user import User
    >>> inputs = {'repo': 'local data directory',
    >>>        'gamertag': 'your gamertag',
    >>>        'squad': ['friend gamertag1', 'friend gamertag2', '... etc'],
    >>>        'file_name': 'match_data.csv'}
    >>> user = User(info=inputs)
        >>> from user import User
>>> inputs = {'repo': 'local data directory',
>>>        'gamertag': 'your gamertag',
>>>        'squad': ['friend gamertag1', 'friend gamertag2', '... etc'],
>>>        'file_name': 'match_data.csv'}
>>> user = User(info=inputs)
Note

None