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
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Mar 11 13:49:40 2019 | |
@author: Nhan Tran | |
""" | |
import numpy as np | |
import pandas as pd | |
import scipy.stats as stats |
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
# This is example, how to use MLJAR service for automatic machine learning and its R-wrapper for churn prediction. | |
# Example is based on data from https://github.com/WLOGSolutions/telco-customer-churn-in-r-and-h2o/tree/master/data | |
# Example by Dominik Krzemiński | |
library(mljar) | |
library(data.table) | |
# Read and clean the dataset | |
all_data <- fread("data/edw_cdr.csv") | |
all_data <- all_data[, !c("month", "year"), with = FALSE] | |
all_data <- all_data[complete.cases(all_data)] |
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
library(googleAnalyticsR) | |
library(tidyr) | |
#Authorized Google Analytics R- this will open a webpage | |
#You must be logged into your Google Analytics account on your web browser | |
ga_auth() | |
#Use the Google Analytics Management API to see a list of Google Analytics accounts you have access to | |
my_accounts <- google_analytics_account_list() | |
View(my_accounts) |
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
PostgreSQL Data Types | AWS DMS Data Types | Redshift Data Types | |
---|---|---|---|
INTEGER | INT4 | INT4 | |
SMALLINT | INT2 | INT2 | |
BIGINT | INT8 | INT8 | |
NUMERIC (p,s) | If precision is 39 or greater, then use STRING. | If the scale is => 0 and =< 37 then: NUMERIC (p,s) If the scale is => 38 and =< 127 then: VARCHAR (Length) | |
DECIMAL(P,S) | If precision is 39 or greater, then use STRING. | If the scale is => 0 and =< 37 then: NUMERIC (p,s) If the scale is => 38 and =< 127 then: VARCHAR (Length) | |
REAL | REAL4 | FLOAT4 | |
DOUBLE | REAL8 | FLOAT8 | |
SMALLSERIAL | INT2 | INT2 | |
SERIAL | INT4 | INT4 |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun Jun 5 18:55:20 2016 | |
@author: cpard | |
""" | |
from sqlalchemy import create_engine | |
import pandas as padas | |
import numpy as np | |
import statsmodels.api as sm |
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
SELECT | |
distance, lat, long, temp | |
FROM | |
(SELECT | |
((ACOS(SIN(39.73756700 * PI() / 180) * | |
SIN((lat/1000) * PI() / 180) + | |
COS(39.73756700 * PI() / 180) * | |
COS((lat/1000) * PI() / 180) * | |
COS((-104.98471790 - | |
(long/1000)) * PI() / 180)) * |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
WITH | |
/* | |
Find every visit | |
*/ | |
all_prospects_visits AS | |
( SELECT DISTINCT prospects.id AS prospect_id, | |
activity.created_at AS visit_date, | |
details AS visit_details, | |
activity.type AS visit_type, | |
activity.created_at created_at |
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
CREATE OR REPLACE FUNCTION f_findall_emails( txt VARCHAR(20000) ) | |
RETURNS VARCHAR(20000) IMMUTABLE AS $$ | |
"""Extract all email addresses found within a given string `txt`. | |
Return: | |
A pipe-delimited string composed of any email addresses found. (e.g. 'john@example.com|jeane@example.com|sara@example.com') | |
Example: | |
mydb=# |
NewerOlder