Package: lifestream
LifestreamLifestream is a Python library to make sense out of your transaction logs. Import a log of your transactional data and let's explore!InstallationUse the package managerpipto install lifestream.pipinstalllifestreamTransactional DataAt a minimum, the transactional data you import should have the following:OrderID assoiated with transactionUnique user id associated with transactionDate of transactionMonetary value of transactionorder_iduser_iddatemonetary_value7681309/13/2020$15.127691324909/13/2020$240.007701142409/13/2020$194.34Is your transactional data in another kind of format? See thecreate_transaction_logfunction below.UsageThis library is inspired bymany of the charts found in this PowerPoint filecreated byProf Daniel McCarthy.Below are some of the methods found within this library.Not all methods are in the readme, so open-up the lifestream.py file for some Easter eggs.Transaction Log CreationNeed to create a transaction log that meets the library's requirements? If your data is as raw as the individually purchased items, try this method.lifestream.create_transaction_log(df,orderid_col,datetime_colcustomerid_col,quantity_col,unitprice_col)dfis a dataframe of your  data.orderid_colthe column in df DataFrame that denotes the unique order_id.datetime_colthe column in df DataFrame that denotes the datetime the purchase was made.customerid_colthe column in df DataFrame that denotes the unique customer_id.quantity_colthe column in df DataFrame that denotes the quantity of items purchased in an order.unitprice_colthe column in df DataFrame that denotes the unit price of items purchased in an order.Monthly Sales ChartWant to plot sales by month?importlifestreamlifestream.sales_chart(transaction_log,datetime_col,ordervalue_col,customerid_col,customer_count=True,title='Sales and Customers Per Month',ylabel1='Number of Customers Per Month',ylabel2='Sales ($) per Month')transaction_logis a dataframe of your transactional data.datetime_colrepresents the column of the transaction_log dataframe which contains the datetime of the transaction.orderid_colrepresents the column of the transaction_log dataframe which contains the monetary value of the transaction.customerid_colrepresents the column of the transaction_log dataframe which contains the unique user id associated with the transaction.customer_countoptionalboolean to indicate whether overlay of new customers per month is desiredtitleoptionalrepresents the title of the chart.ylabel1optionalrepresents the label on the y-axis of the line chart.ylabel2optionalrepresents the label on the y-axis of the bar chart.Cohort Retention ChartWant to dig into basic cohort analyses? Plot how many users from a cohort are still spending in subsequent months.lifestream.cohort_retention_chart(transaction_log,datetime_col,customerid_col,ordervalue_col,cohort1,cohort2,cohort3,title,ylabel)transaction_logis a dataframe of your transactional data.datetime_colrepresents the column of the dataframe which contains the datetime of the transaction.customerid_colrepresents the column of the dataframe which contains the unique user id associated with the transaction.ordervalue_colrepresents the column of the dataframe which contains the monetary value of the transaction.cohort1,cohort2,cohort3are the three cohorts you are interested in, expressed as 'YYYY-MM' string.titleoptionalis the title for the plot.ylabeloptionalis the label for the y-axis of the plot.Monthly Acquisition ChartPlot how many new users you are acquiring per month.lifestream.new_customers_chart(transaction_log,datetime_col,customerid_col,title,xlabel,ylabel,kind)transaction_logis a dataframe of your transactional data.datetime_colrepresents the column of the dataframe which contains the datetime of the transaction.customerid_colrepresents the column of the dataframe which contains the unique user id associated with the transaction.titleoptionalrepresents the title of the chart.xlabeloptionalrepresents the x-axis of the chart.ylabeloptionalrepresents the y-axis of the chart.kindoptionalrepresents the kind of chart. see the pandas library documentation for the plot method to understand what is available.The C3 Chart 🤩lifestream.c3chart(transaction_log,customer_id,datetime_col,ordervalue_col,title="Total Quarterly Sales by Acquisition Cohort Over Time")transaction_logis a dataframe of your transactional data.customerid_colrepresents the column of the dataframe which contains the unique user id associated with the transaction.datetime_colrepresents the column of the dataframe which contains the datetime of the transaction.ordervalue_colrepresents the column of the dataframe which contains the monetary value of the transaction.titleoptionalrepresents the title of the chart.ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.LicenseMIT