Posts

Showing posts from November, 2020

Python Automation for Group by and Line Chart

  def   conversion_rate ( dataframe ,   column_names ):      # Total number of converted users      column_conv  =  dataframe [ dataframe [ 'converted' ]  ==  True ] \                        . groupby ( column_names )[ 'user_id' ] . nunique ()      # Total number users      column_total  =  dataframe . groupby ( column_names )[ 'user_id' ] . nunique ()               # Conversion rate       conversion_rate  =  column_conv / column_total           # Fill missing values with 0      conversion_rate  =  conversion_rate . fill...

A/B test using Python

Calculating KPIs You're now going to take what you've learned and work through calculating a KPI yourself. Specifically, you'll calculate the average amount paid per purchase within a user's first 28 days using the  purchase_data  DataFrame from before. This KPI can provide a sense of the popularity of different in-app purchase price points to users within their first month. max_purchase_date  =  current_date  -  timedelta ( days = 28 ) # Filter to only include users who registered before our max date purchase_data_filt  =  purchase_data [ purchase_data . reg_date  <  max_purchase_date ] # Filter to contain only purchases within the first 28 days of registration purchase_data_filt  =  purchase_data_filt [( purchase_data_filt . date  <=            ...

SQL triggers

  -- Create the trigger CREATE   TRIGGER   TrackRetiredProducts ON   Products AFTER   DELETE AS      INSERT   INTO   RetiredProducts   ( Product ,   Measure )      SELECT   Product ,   Measure      FROM   deleted ; Insted of Trigger The company doesn't want regular users to add discounts. Only the Sales Manager should be able to do that. To prevent such changes, you need to create a new trigger called  PreventNewDiscounts . The trigger should be attached to the  Discounts  table and prevent new rows from being added to the table. -- Create a new trigger Create   Trigger   PreventNewDiscounts ON   Discounts INSTEAD   OF   INSERT AS      RAISERROR   ( 'You are not allowed to add discounts for existing customers.   ...