Module Import alias identifier ImportFrom alias ImportFrom alias alias ImportFrom alias ImportFrom alias Import alias identifier Import alias Import alias Import alias FunctionDef arguments args NameParam NameParam defaults Num body Expr Str If UnaryOpNot Call AttributeLoad Call NameLoad BinOpDiv BinOpMult Num Num NameLoad attr body Raise Call NameLoad Str Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword Str keyword NameLoad Assign NameStore ListLoad TupleLoad NameLoad Str TupleLoad NameLoad Str TupleLoad NameLoad Str TupleLoad NameLoad Str TupleLoad NameLoad Str TupleLoad NameLoad Str Assign NameStore ListLoad TupleLoad NameLoad Str TupleLoad NameLoad Str Assign NameStore ListLoad Assign NameStore ListComp BinOpMult BinOpAdd NameLoad Num NameLoad comprehension NameStore Call NameLoad BinOpDiv BinOpMult BinOpMult Num Num Num NameLoad Assign NameStore Call NameLoad NameLoad For NameStore Call NameLoad NameLoad keyword Str body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Num body Expr Str With Call NameLoad NameLoad Str NameStore body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr ListLoad Str Str Str Str Str FunctionDef arguments args NameParam defaults body If CompareIs NameLoad NameLoad body Return NameLoad orelse If Call NameLoad NameLoad NameLoad body Return Call NameLoad Call NameLoad NameLoad NameLoad orelse Return Call NameLoad NameLoad decorator_list For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr ListComp Call NameLoad NameLoad comprehension NameStore NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str With Call NameLoad NameLoad Str NameStore body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign SubscriptStore NameLoad Slice Num Num Call NameLoad NameLoad SubscriptLoad NameLoad Slice Num Num Assign SubscriptStore NameLoad Index Num Call NameLoad SubscriptLoad NameLoad Index Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Num body Expr Str Assign NameStore ListLoad If CompareEq Call NameLoad NameLoad Num body Return NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Assign NameStore ListLoad NameLoad Assign NameStore BinOpAdd BinOpAdd Call NameLoad SubscriptLoad Call AttributeLoad AttributeLoad SubscriptLoad NameLoad Index Num attr attr Index Num Str Call NameLoad SubscriptLoad Call AttributeLoad AttributeLoad SubscriptLoad NameLoad Index Num attr attr Index Num Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign TupleStore NameStore NameStore NameLoad Assign AttributeStore NameLoad attr NameLoad Assign NameStore SubscriptLoad Call AttributeLoad SubscriptLoad SubscriptLoad Call NameLoad NameLoad Index Str Index Str attr Index Num If CompareEq NameLoad Str body Assign NameStore Call NameLoad GeneratorExp NameLoad comprehension NameStore NameLoad CompareIsNot NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call NameLoad GeneratorExp NameLoad comprehension NameStore NameLoad comprehension NameStore NameLoad CompareIsNot NameLoad NameLoad If CompareNotEq NameLoad Num body Expr Call AttributeLoad NameLoad attr ListLoad NameLoad BinOpAdd NameLoad NameLoad SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam NameParam defaults body For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad keyword Lambda arguments args NameParam defaults Call NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr body Expr Yield NameLoad decorator_list Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore ListComp Call NameLoad NameLoad Call NameLoad AttributeLoad SubscriptLoad NameLoad Index Num attr comprehension NameStore NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Assert BoolOpAnd CompareEq Call NameLoad NameLoad Call NameLoad NameLoad CompareEq Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore SubscriptLoad Call AttributeLoad AttributeLoad SubscriptLoad NameLoad Index Num attr attr Index Num For NameStore Call NameLoad Lambda arguments args NameParam defaults BoolOpAnd CompareEq AttributeLoad NameLoad attr Str CompareGt AttributeLoad NameLoad attr Num NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Num While CompareGt NameLoad Num body Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore BinOpAdd AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr keyword NameLoad If CompareGt SubscriptLoad Call AttributeLoad NameLoad attr Index Num NameLoad body AugAssignSub NameStore Call AttributeLoad NameLoad attr keyword Num Expr Call AttributeLoad NameLoad attr Call NameLoad Str AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad AugAssignSub NameStore NameLoad AugAssignAdd NameStore NameLoad Assign NameStore BinOpMult NameLoad Num Return Call NameLoad NameLoad keyword Lambda arguments args NameParam defaults Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad Assign NameStore ListLoad Str Str Str Str Str Str For NameStore NameLoad body Expr Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Str body Expr Str If CompareEq NameLoad Str body Return BinOpAdd BinOpAdd BinOpAdd BinOpMult BinOpMult BinOpMult Call AttributeLoad NameLoad attr Num Num Num BinOpMult BinOpMult AttributeLoad NameLoad attr Num Num BinOpMult AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr orelse If CompareEq NameLoad Str body Return BinOpAdd BinOpAdd BinOpMult BinOpMult Call AttributeLoad NameLoad attr Num Num BinOpMult AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr orelse Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore BinOpMult SubscriptLoad NameLoad Index Call NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Num Return BinOpSub NameLoad Call NameLoad AttributeLoad NameLoad attr keyword Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore BinOpDiv BinOpMult Num Num NameLoad Return ListComp ListLoad Call NameLoad Call AttributeLoad NameLoad attr BinOpDiv NameLoad NameLoad BinOpMod NameLoad NameLoad comprehension NameStore NameLoad decorator_list
N/A N/A bandicoot bc bandicoot.helper.group group_records bandicoot.core User Record bisect bisect_right functools partial N/A datetime dt N/A itertools N/A csv N/A math create_punchcards N/A N/A user split_interval N/A 60 N/A N/A 
    Computes raw indicators (e.g. number of outgoing calls) for intervals of ~1 hour
    across each week of user data. These "punchcards" are returned in a nested list
    with each sublist containing [user.name, channel, weekday, section, value].

    Parameters
    ----------
    user : object
        The user to create punchcards for.
    split_interval : int
        The interval in minutes for which each indicator is computed. Defaults to 60.
        Needs to be able to split a day (24*60 minutes) evenly.
     N/A N/A N/A N/A N/A float N/A N/A 24 60 split_interval is_integer N/A N/A N/A ValueError The minute interval set for the punchcard structure does not evenly divide the day! N/A contacts_in N/A partial N/A N/A bc individual number_of_contacts direction in interaction callandtext summary None N/A contacts_out N/A partial N/A N/A bc individual number_of_contacts direction out interaction callandtext summary None N/A calls_in N/A partial N/A N/A bc individual number_of_interactions direction in interaction call summary None N/A calls_out N/A partial N/A N/A bc individual number_of_interactions direction out interaction call summary None N/A texts_in N/A partial N/A N/A bc individual number_of_interactions direction in interaction text summary None N/A texts_out N/A partial N/A N/A bc individual number_of_interactions direction out interaction text summary None N/A time_spent_in N/A partial N/A N/A bc individual call_duration direction in interaction call summary None N/A time_spent_out N/A partial N/A N/A bc individual call_duration direction out interaction call summary None N/A core_func N/A N/A contacts_in scalar N/A contacts_out scalar N/A calls_in scalar N/A calls_out scalar N/A texts_in scalar N/A texts_out scalar N/A time_func N/A N/A time_spent_in summarystats N/A time_spent_out summarystats N/A pc N/A N/A sections N/A N/A N/A i 1 split_interval N/A i N/A range N/A N/A N/A 7 24 60 split_interval N/A temp_user N/A _extract_user_info user N/A grouped_records N/A group_records user groupby week N/A N/A week_records N/A list grouped_records N/A time_spent_rec N/A _transform_to_time_spent week_records split_interval sections N/A N/A N/A pc extend N/A _calculate_channels week_records sections split_interval core_func temp_user N/A N/A N/A pc extend N/A _calculate_channels time_spent_rec sections split_interval time_func temp_user N/A len core_func N/A pc N/A to_csv N/A N/A punchcards filename digits N/A 5 N/A N/A 
    Exports a list of punchcards to a specified filename in the CSV format.

    Parameters
    ----------
    punchcards : list
        The punchcards to export.
    filename : string
        Path for the exported CSV file.
     N/A N/A open filename wb f N/A N/A w N/A N/A csv writer f N/A N/A N/A w writerow N/A year_week channel weekday section value make_repr N/A N/A item N/A N/A N/A N/A item None N/A N/A None N/A N/A N/A isinstance item float N/A N/A N/A repr N/A round item digits N/A N/A N/A str item N/A N/A row punchcards N/A N/A N/A N/A w writerow N/A N/A make_repr item N/A item row N/A read_csv N/A N/A filename N/A N/A N/A 
    Read a list of punchcards from a CSV file.
     N/A N/A open filename rb f N/A N/A r N/A N/A csv reader f N/A N/A next r N/A pc N/A list r N/A N/A i row N/A enumerate pc N/A N/A N/A row N/A 1 4 N/A map int N/A row N/A 1 4 N/A N/A row N/A 4 N/A float N/A row N/A 4 N/A pc N/A _calculate_channels N/A N/A records sections split_interval channel_funcs user c_start N/A 0 N/A N/A 
    Used to group a list of records across a week as defined by the supplied sections.
    Outputs a list containing records in each section and a list with info to identify those sections.

    Parameters
    ----------
    records : list
        The week of records to calculate the channels for.
    sections : list
        The list of sections for grouping. Each section will have an integer value
        stating the minutes away from midnight between Sunday and Monday.
    split_interval : int
        The interval in minutes for which each indicator is computed.
    channel_funcs : list
        Indicator functions that generate the values for the punchcard.
    user : object
        The user to calculate channels for.
    c_start : num
        Start numbering of channels from this value. Optional parameter. Default value of 0.
        Used when adding channels to the same user using different lists of records.
     N/A week_matrix N/A N/A N/A N/A len records 0 N/A N/A week_matrix N/A N/A N/A isinstance records list N/A N/A records N/A records N/A year_week N/A N/A N/A str N/A N/A N/A N/A N/A records N/A 0 datetime isocalendar N/A 0 - N/A str N/A N/A N/A N/A N/A records N/A 0 datetime isocalendar N/A 1 N/A N/A section_lists section_id N/A _punchcard_grouping records sections split_interval N/A N/A c fun N/A enumerate channel_funcs N/A N/A N/A b section_records N/A enumerate section_lists N/A N/A N/A indicator_fun return_type fun N/A N/A user _records section_records N/A output N/A N/A N/A N/A N/A N/A indicator_fun user N/A allweek N/A allday values N/A 0 N/A N/A return_type scalar N/A N/A indicator N/A sum N/A d N/A d output N/A d None N/A N/A N/A return_type summarystats N/A N/A indicator N/A sum N/A d N/A group output N/A d group N/A d None N/A N/A indicator 0 N/A N/A N/A N/A week_matrix append N/A year_week N/A c c_start N/A N/A section_id N/A b N/A 0 N/A N/A section_id N/A b N/A 1 N/A float indicator N/A week_matrix N/A _punchcard_grouping N/A N/A records sections split_interval N/A N/A N/A 
    Used to group a list of records across a week as defined by the supplied sections.
    Outputs a list containing records in each section and a list with info to identify those sections.

    Parameters
    ----------
    records : list
        The week of records to group across the different weekdays/sections.
    sections : list
        The list of sections for grouping. Each section will have an integer value
        stating the minutes away from midnight between Sunday and Monday.
    split_interval : int
        The interval in minutes for which each indicator is computed.
     _group_by_weektime N/A N/A records sections N/A N/A N/A N/A _ group N/A N/A itertools groupby records key N/A N/A N/A r N/A N/A bisect_right sections N/A _find_weektime N/A r datetime N/A N/A N/A group N/A N/A section_records N/A _group_by_weektime records sections N/A section_lists N/A _extract_list_from_generator section_records N/A section_indices N/A N/A bisect_right sections N/A _find_weektime N/A N/A r_list N/A 0 datetime N/A r_list section_lists N/A section_id N/A _find_day_section_from_indices section_indices split_interval N/A N/A N/A N/A len section_lists N/A len section_id N/A N/A len section_indices N/A len N/A set section_indices N/A N/A section_lists section_id N/A _transform_to_time_spent N/A N/A records split_interval sections N/A N/A N/A 
    Each call that crosses a boundary of the sections in the punchcard is split.
    These new records contain the amount of time (in record.call_duration) spent
    talking in that specific section.
     N/A t_records N/A N/A week_nr N/A N/A N/A N/A N/A records N/A 0 datetime isocalendar N/A 1 N/A r N/A filter N/A N/A N/A rec N/A N/A N/A N/A rec interaction call N/A N/A rec call_duration 0 records N/A N/A t_left N/A r call_duration N/A t_to_next_section N/A _seconds_to_section_split r sections N/A t_spent_total 0 N/A N/A t_left 0 N/A N/A t_spent N/A min t_to_next_section t_left N/A dt_new N/A N/A r datetime N/A N/A dt timedelta seconds t_spent_total N/A N/A N/A N/A N/A dt_new isocalendar N/A 1 week_nr N/A N/A dt_new N/A N/A dt timedelta days 7 N/A N/A N/A t_records append N/A Record call N/A r direction None dt_new t_spent None N/A t_left t_spent N/A t_spent_total t_spent N/A t_to_next_section N/A split_interval 60 N/A N/A sorted t_records key N/A N/A N/A r N/A N/A _find_weektime N/A r datetime N/A _extract_user_info N/A N/A user N/A N/A N/A 
    Creates a new user class with extracted user attributes for later use.
    A new user is needed when wanting to avoid overwritting e.g. ``user.records``.
     N/A temp_user N/A User N/A copy_attributes N/A antennas name night_start night_end weekend home N/A attr copy_attributes N/A N/A N/A setattr temp_user attr N/A getattr user attr N/A temp_user N/A _find_weektime N/A N/A datetime time_type N/A min N/A N/A 
    Finds the minutes/seconds aways from midnight between Sunday and Monday.

    Parameters
    ----------
    datetime : datetime
        The date and time that needs to be converted.
    time_type : 'min' or 'sec'
        States whether the time difference should be specified in seconds or minutes.
     N/A N/A time_type sec N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A datetime weekday 24 60 60 N/A N/A N/A datetime hour 60 60 N/A N/A datetime minute 60 N/A datetime second N/A N/A N/A time_type min N/A N/A N/A N/A N/A N/A N/A N/A datetime weekday 24 60 N/A N/A datetime hour 60 N/A datetime minute N/A N/A N/A ValueError Invalid time type specified. N/A _extract_list_from_generator N/A N/A generator N/A N/A N/A 
    Iterates over a generator to extract all the objects and add them to a list.
    Useful when the objects have to be used multiple times.
     N/A extracted N/A N/A i generator N/A N/A N/A N/A extracted append N/A list i N/A extracted N/A _seconds_to_section_split N/A N/A record sections N/A N/A N/A 
    Finds the seconds to the next section from the datetime of a record.
     N/A next_section N/A N/A sections N/A N/A bisect_right sections N/A _find_weektime N/A record datetime 60 N/A N/A next_section N/A _find_weektime N/A record datetime time_type sec N/A _find_day_section_from_indices N/A N/A indices split_interval N/A N/A N/A 
    Returns a list with [weekday, section] identifiers found using a list of indices.
     N/A cells_day N/A N/A 24 60 split_interval N/A N/A N/A N/A int N/A N/A math floor N/A i cells_day N/A i cells_day N/A i indices N/A