@@ -0,0 +1,2709 @@
+from bandicoot.helper.group import grouping%0Aimport bandicoot as bc%0A%0A%0A# Loading a User%0AU = bc.read_csv('ego', 'data/', 'data/antennas.csv')%0A%0A%0A#######################%0A# Export visulization #%0A#######################%0A%0Abc.visualization.export(U, 'my-viz-path')%0A%0A%0A#########################################%0A# Run individual and spatial indicators #%0A#########################################%0A%0Abc.individual.percent_initiated_conversations(U)%0Abc.spatial.number_of_antennas(U)%0Abc.spatial.radius_of_gyration(U)%0A%0A%0A######################################%0A# Group indicators by weeks or month #%0A######################################%0A%0A# The groupby keyword controls the aggregation:%0A# - groupby='week' to divide by week (by default),%0A# - groupby='month' to divide by month,%0A# - groupby=None to aggregate all values.%0A%0Abc.individual.active_days(U, groupby='week')%0Abc.individual.active_days(U, groupby='month')%0Abc.individual.active_days(U, groupby=None)  # No grouping%0A%0A%0A################################%0A# Returning extended summaries #%0A################################%0A%0A# The summary keyword can take three values:%0A# - summary='default' to return mean and standard deviation,%0A# - summary='extended' for the second type of indicators, to return mean, std,%0A#   median, skewness and std of the distribution,%0A# - summary=None to return the full distribution.%0A%0Abc.individual.call_duration(U)%0Abc.individual.call_duration(U, summary='extended')%0Abc.individual.call_duration(U, summary=None)%0A%0A############################%0A# Splitting days and weeks #%0A############################%0A%0A# split_week divide records by 'all week', 'weekday', and 'weekend'.%0A# split_day divide records by 'all day', 'day', and 'night'.%0A%0Abc.individual.active_days(U, split_week=True, split_day=True)%0A%0A########################%0A# Exporting indicators #%0A########################%0A%0A# The function bc.utils.all computes automatically all indicators for a single%0A# user. You can use the same keywords to group by week/month/all time range, or%0A# return extended statistics.%0A%0Afeatures = bc.utils.all(U, groupby=None)%0A%0Abc.to_csv(features, 'demo_export_user.csv')%0Abc.to_json(features, 'demo_export_user.json')%0A%0A#######################%0A# Extending bandicoot #%0A#######################%0A%0A# You can easily develop your indicator using the @grouping decorator. You only%0A# need to write a function taking as input a list of records and returning an%0A# integer or a list of integers (for a distribution). The @grouping decorator%0A# wraps the function and call it for each group of weeks.%0A%0A%0A@grouping(interaction='call')%0Adef shortest_call(records):%0A    in_durations = (r.call_duration for r in records)%0A    return min(in_durations)%0A%0Ashortest_call(U)%0Ashortest_call(U, split_day=True)%0A

Add one demo Python file with code examples