Skip to content

Commit

Permalink
Merge pull request #6 from pjrigali/dev
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
pjrigali authored Aug 24, 2021
2 parents 2bbb545 + 5f1e0e7 commit 1e4b41a
Show file tree
Hide file tree
Showing 10 changed files with 777 additions and 181 deletions.
44 changes: 37 additions & 7 deletions Classes/call_of_duty.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@


class CallofDuty:
"""
Calculate stats for all maps/modes for each squad memeber.
Parameters
----------
hacker_data : bool, default is False.
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.
squad_data : bool, default is False.
If True, will build the Squad class.
Examples
--------
>>> from Classes.call_of_duty import CallofDuty
>>> cod = CallofDuty(hacker_data=False, squad_data=True)
This will calculate and build the CallofDuty class.
"""

def __init__(self, hacker_data: bool = False, squad_data: bool = False):
self._User = User(info=user_inputs)
Expand All @@ -33,44 +52,55 @@ def __repr__(self):

@property
def whole(self) -> pd.DataFrame:
"""Returns the unedited player matches DataFrame"""
return self._whole

@property
def gun_dictionary(self) -> pd.DataFrame:
def gun_dictionary(self) -> dict:
"""Returns a dict of gun names"""
return self._gun_dic

@property
def last_match_date_time(self) -> pd.DataFrame:
def last_match_date_time(self):
"""Returns a Timestamp of the latest game in the players data. Useful when scraping from Cod Tracker"""
return self._last_match_date_time

@property
def name_uno_dict(self) -> pd.DataFrame:
def name_uno_dict(self) -> dict:
"""Returns a dict of gamertags and respective unos"""
return self._name_uno_dict

@property
def my_uno(self) -> pd.DataFrame:
def my_uno(self) -> str:
"""Returns the user uno value"""
return self._my_uno

@property
def our_df(self) -> pd.DataFrame:
"""Returns a DataFrame of all data related to player and there teammates"""
return self._our_df

@property
def other_df(self) -> pd.DataFrame:
"""Returns a DataFrame of all data related to other teams in a lobby"""
return self._other_df

@property
def hacker_df(self) -> pd.DataFrame:
"""If a hacker DataFrame is provided, will return just the hacker DataFrame"""
return self._hacker_df

@property
def name_uno_dict_hacker(self) -> pd.DataFrame:
def name_uno_dict_hacker(self) -> dict:
"""If a hacker DataFrame is provided, will return the gamertags: unos for the hacker DataFrame"""
return self._name_uno_dict_hacker

@property
def user(self) -> pd.DataFrame:
def user(self) -> User:
"""Returns a User class object of related info to the user"""
return self._User

@property
def squad(self) -> pd.DataFrame:
def squad(self) -> Squad:
"""Returns a Squad class object of stats related to the user squad mates"""
return self._Squad
49 changes: 48 additions & 1 deletion Classes/document_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,37 @@

@dataclass
class DocumentFilter:

"""
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, default is None
Map filter. Either 'mp_e' for Rebirth and 'mp_d' for Verdansk.
mode_choice : str, default is None
Mode filter. Either 'solo', 'duo', 'trio', or 'quad'.
username : str, default is None
Filter by a players username. Can cause errors if same username as another player.
uno : str, default is None
Filter by a players uno.
username_dic : dict, default is None
Required if 'username' or 'username_lst' is used. {username1: uno1, username2: uno2, etc}.
username_lst : List[str], default is None
Filter using a list of usernames.
Examples
--------
>>> from Classes.document_filter import DocumentFilter
>>> doc = DocumentFilter(original_df=cod.our_df, map_choice='mp_e', mode_choice='quad')
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.
"""
def __init__(self,
original_df: pd.DataFrame,
map_choice: Optional[str] = None,
Expand Down Expand Up @@ -48,35 +78,52 @@ def __init__(self,
self._username = username
self._uno = uno
self._username_lst = username_lst
self._username_dic = username_dic

def __repr__(self):
return 'DocumentFilter'

@property
def df(self) -> pd.DataFrame:
"""Returns the filtered DataFrame"""
return self._df

@property
def map_choice(self) -> Optional[str]:
"""Returns the map used to filter"""
return self._map

@property
def mode_choice(self) -> Optional[str]:
"""Returns the mode used to filter"""
return self._mode

@property
def uno(self) -> Optional[str]:
"""Returns the uno used to filter"""
return self._uno

@property
def username(self) -> Optional[str]:
"""Returns the username used to filter"""
return self._username

@property
def username_lst(self) -> Optional[List[str]]:
"""Returns the username list used to filter"""
return self._username_lst

@property
def unique_ids(self) -> Optional[List[str]]:
"""Returns unique match ids from the filtered DataFrame"""
return self._unique_id_lst

@property
def ids(self) -> Optional[List[str]]:
"""Returns match ids from the filtered DataFrame"""
return self._id_lst

@property
def username_dic(self) -> Optional[dict]:
"""Returns username: uno dict"""
return self._username_dic
Loading

0 comments on commit 1e4b41a

Please sign in to comment.