Python Tutorial : Identifying and understanding KPIs

Learn to identify and calculate KPIs using a meditation app example with subscription and one-off purchases. The tutorial loads two CSV files with pandas, merges them on user ID, then computes the free-trial-to-paying conversion rate across different time intervals to assess stability and correlation with retention and spending.
Chapters
Great work on the exercises. Now let's dive into KPIs. The example we will use throughout this course is that of a mobile app that offers meditation services for a paid subscription as well as one off in app purchases. The app is growing quickly and we are motivated to maintain a strong free trial to paying user conversion rate. Additionally, we want to maintain strength in a variety of other business areas as we will see. While this is a very specific example, we can imagine interchanging users, meditation app and purchases with other nouns and KPIs and the same mathematical techniques would still apply. We have two data sets related to our app. First is a set of user demographics tied to a unique user ID number. Let's import this file CustomerDemographics CSV with the Pandas Readcsv method. As we can see, it includes a broad set of demographic information. The second is a set of user actions called customersubscriptions CSV containing the date the trial period ended, the date of purchase if they purchased, and the price they paid upon subscribing in cents. For now we lets consider the KPI of conversion rate. We will consider a variety of others throughout this course. One question in defining our KPI is Over what interval should we consider the conversion rate? The conversion immediately after lapse one week after one month One way to decide this is to see the generalizability of these statistics across different demographics groups. Stability in this way is desired so we don't need custom KPIs for each breakdown. A second is to see if one is more correlated with important factors like retention or spending than the others. To begin answering these questions, we must match our demographics data to our subscription data so that we can explore specific relationships. We will do this with the Pandas merge method. This performs the equivalent of a SQL join on two data frames. There are two ways of calling this method, either as a method of Pandas or as a method of a dataframe object. We will only consider the latter case here, but they are equivalent. As in SQL, we have a left and right table. We call the merge method on one of our data frames and this is considered the left dataframe. In this case, this will be our demographics data set. Next we specify the right data frame as our first argument in this case the subscriptions data. Then we specify the how argument. This can be one of four values inner, outer, left, or right, each analogous to a SQL join. Understanding SQL is not important for this course. It suffices to say that these arguments specify the behavior of which rows are returned in the final output. For our purpose, we'll use an inner join which returns all rows that are matched between the two data frames. The next argument is the on argument. This is a list of fields that appear in both data frames that we want to match the rows on. There is a way to specify this argument when the columns differ in name, but we will not cover that here we will match on the UID field. As we can see in the output, the rows are associated with a corresponding row from the other data frame. Our next step is to aggregate our newly combined data set and to calculate the potential KPIs we are interested in. The exercises will allow you to practice the techniques covered here with another interesting aspect of our Meditation app Data.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







