
groups variable is a dictionary whose keys are the computed unique groups and corresponding values being the axis labels belonging to each group. The groupby() function returns a GroupBy object, but essentially describes how the rows of the original data set has been split. For example, the expression oupby(‘month’) will split our current DataFrame by month. Groupby essentially splits the data into different groups depending on a variable of your choice. There’s further power put into your hands by mastering the Pandas “groupby()” functionality. The describe() output varies depending on whether you apply it to a numeric or character column. describe() function is a useful summarisation tool that will quickly display statistics for any variable or group it is applied to. The full range of basic statistics that are quickly calculable and built into the base Pandas package are: Function The need for custom functions is minimal unless you have very specific requirements. # Number of non-null unique network entries

# How many entries are there for each month? # How many seconds of phone calls are recorded in total?ĭata = 'call'].sum() # What was the longest phone call / data entry? For example, mean, max, min, standard deviations and more for columns are easily calculable: # How many rows the dataset Once the data has been loaded into Python, Pandas makes the calculation of different statistics very simple. import pandas as pdĭata = pd.om_csv('phone_data.csv')ĭata = data.apply(, dayfirst=True) Summarising the DataFrame Phone numbers were removed for privacy. The date column can be parsed using the extremely handy dateutil library.


I analysed this type of data using Pandas during my work on KillBiller. In order to demonstrate the effectiveness and simplicity of the grouping commands, we will need some data. For an example dataset, I have extracted my own mobile phone usage records.
