This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- * Data Extraction and Analysis: | |
-- Q: What are the start and end dates of the experiment? | |
-- A: 2023-01-25 to 2023-02-06 | |
SELECT MIN(join_dt), MAX(join_dt) | |
FROM groups; | |
-- Q: How many total users were in the experiment? | |
-- A: 48,943 | |
SELECT COUNT(uid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Load the Raw Data: | |
df = pd.read_csv('crimesportugal.csv', delimiter=';') | |
# Define Column Names: | |
column_names = { | |
'total': 'Total Crime', | |
'vdom': 'Domestic Violence', | |
'fur_veiculo': 'Vehicles Stolen', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Cohort definition: | |
WITH cohort_users AS ( | |
SELECT user_id | |
FROM sessions | |
WHERE session_start > '2023-01-04' | |
GROUP BY user_id | |
HAVING COUNT(session_id) > 7 | |
), | |
-- Using for calculating the distance between two airports in the final query: |