Created
March 10, 2023 11:43
-
-
Save jdunkerley/ad0623c935249767045c5043fe716ac8 to your computer and use it in GitHub Desktop.
Preppin Data Week 3 - in Enso
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
from Standard.Base import all | |
from Standard.Table import all | |
from Standard.Database import all | |
import Standard.Visualization | |
func1 operator11 = | |
operator12 = operator11.split "-" | |
operator13 = operator12.first | |
operator13 | |
func2 operator27 = | |
operator28 = operator27.drop 1 | |
operator29 = Integer.parse operator28 | |
operator29 | |
main = | |
operator3 = enso_project.data/"PD 2023 Wk 1 Input.csv" . read | |
operator1 = operator3.get 'Transaction Date' | |
operator2 = operator1.parse Date "dd/MM/yyyy 00:00:00" | |
operator4 = operator3.set operator2 | |
operator5 = operator2.first | |
operator6 = _.format "EEEE" | |
operator7 = operator2.map operator6 | |
operator8 = operator7.rename "Day of Week" | |
operator9 = operator4.set operator8 | |
operator10 = operator9.get 'Transaction Code' | |
operator11 = operator10.first | |
operator13 = Main.func1 operator11 | |
operator12 = operator10.map Main.func1 | |
operator14 = operator12.rename "Bank" | |
operator15 = operator9.set operator14 | |
operator16 = operator15.set 'IF [Online or In-Person] == 1 THEN "Online" ELSE "In-Person"' "Online or In-Person" | |
operator17 = operator16.aggregate [Aggregate_Column.Group_By "Bank", Aggregate_Column.Sum "Value" "Value"] | |
operator18 = operator16.aggregate [Aggregate_Column.Group_By "Bank", Aggregate_Column.Group_By "Online or In-Person", Aggregate_Column.Group_By "Day of Week", Aggregate_Column.Sum "Value" "Value"] | |
operator19 = operator16.filter 'Bank' (Filter_Condition.Equal "DSB") | |
operator20 = operator19.get 'Transaction Date' | |
operator21 = operator20.map .quarter | |
operator22 = operator21.rename "Quarter" | |
operator23 = operator19.set operator22 | |
operator24 = enso_project.data/"Targets.csv" . read | |
operator25 = operator24.transpose "Online or In-Person" | |
operator26 = operator25.get "Name" | |
operator27 = operator26.first | |
operator29 = Main.func2 operator27 | |
operator28 = operator26.map Main.func2 | |
operator30 = operator28.rename "Quarter" | |
operator31 = operator25.set operator30 | |
operator32 = operator31.remove_columns "Name" | |
operator33 = operator32.rename_columns ["Online or In-Person", "Quarterly Targets", "Quarter"] | |
operator34 = operator23.aggregate [Aggregate_Column.Group_By "Online or In-Person", Aggregate_Column.Group_By "Quarter", Aggregate_Column.Sum "Value" "Value"] | |
operator35 = operator34.join operator33 Join_Kind.Inner ["Online or In-Person", "Quarter"] | |
operator36 = operator35.set "[Value]-[Quarterly Targets]" "Variance to Target" | |
operator37 = operator16.aggregate [Aggregate_Column.Group_By "Bank", Aggregate_Column.Group_By "Customer Code", Aggregate_Column.Sum "Value" "Value"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment