Join Recipe(2)

Hands-on joining Datasets

In the hands-on lessons of Basics 101 and Basics 102, you created a project, imported a dataset, and did some data exploration and preparation steps.

In this hands-on lesson, we’ll demonstrate another key visual recipe: Join.

Resume/Create Your Project

If you completed all of the steps in the Basics 102 project, you can resume the same project for this lesson. All you need to do is download a copy of the customers CSV file and upload it to the project.

Alternatively, you can create a starter project with these same steps completed. From the Dataiku homepage, click +New Project > DSS Tutorials > Core Designer / Basics > Basics 103.

Click on Go to Flow.

Join Datasets

In Basics 102, we created a dataset of orders grouped by unique customers. Now we have a dataset with more information about our customers. We can use the Join recipe to enrich the customers dataset with the information of the orders_by_customer dataset.

Hint
A screencast at the end of the page recaps the instructions described here.

Open the customers dataset by double-clicking on its icon in the Flow. Each row in this dataset represents a separate customer, and records:

  • the unique customer ID
  • the customer’s gender
  • the customer’s birthdate
  • the user agent most commonly used by the customer
  • the customer’s IP address
  • whether the customer is part of Haiku T-Shirts’ marketing campaign

Note
Take a few minutes to explore it with tools like Analyze. Also, note the gray portion of the gender column’s data quality bar representing missing values.

We are now ready to enrich the customers dataset with information about the aggregate orders customers have made.

  • From the Actions menu, choose Join with… from the list of visual recipes.
  • Select orders_by_customer as the second input dataset.
  • Change the name of the output dataset to customers_orders_joined.
  • Click Create Recipe.

The Join recipe has several steps (shown in the left navigation bar). The core step is the Join step, where you choose how to match rows between the datasets. In this case, we want to match rows from customers and orders_by_customer that have the same value of customerID and customer_id, respectively. Note that Dataiku DSS has automatically discovered the join key, even though the columns have different names.

By default, the Join recipe performs a left join, which retains all rows in the left dataset, even if there is no matching information in the right. Since we only want to work with customers who have made at least one order, let’s modify the join type.

Note
Types of joins
There are multiple methods for joining two datasets; the method you choose will depend upon your data and your goals in analysis.

  • Left join keeps all rows of the left dataset and adds information from the right dataset when there is a match. This is useful when you need to retain all the information in the rows of the left dataset, and the right dataset is providing extra, possibly incomplete, information.
  • Inner join keeps only the rows that that match in both datasets. This is useful when only the rows with complete information from both datasets will be useful downflow.
  • Outer join keeps all rows from both datasets, combining rows where there is a match. This is useful when you need to retain all the information in both datasets.
  • Right join is similar to a left join, but keeps all rows of the right dataset and adds information from the left dataset when there is a match.
  • Cross join is a Cartesian product that matches all rows of the left dataset with all rows of the right dataset. This is useful when you need to compare every row in one dataset to every row of another
  • Advanced join provides custom options for row selection and deduplication for when none of the other options are suitable.
    By default, the Join recipe performs a Left join.
  • Click on the Left Join indicator.
  • Navigate to Join Type.
  • Click on Inner join and then Close.

This will retain only the customers who have made an order, and remove the others from the output dataset.

The next step is to choose which columns to retain from the input datasets. We want to carry over all columns from both datasets into the output dataset, with the exception of customer_id (since the customerID column from the customers dataset should be sufficient).

  • Click on the Selected columns step.
  • Uncheck the customer_id column in the orders_by_customer dataset.

Click Run to execute the recipe, updating the schema in the process.

When it is done, click Explore dataset customers_orders_joined at the bottom of the screen to explore the customers_orders_joined dataset.

The following video goes through what we just covered.

//

What’s next?

So far all of your work has been in the Flow. Now it’s time to learn about the Lab!

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,546评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,224评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,911评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,737评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,753评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,598评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,338评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,249评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,696评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,888评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,013评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,731评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,348评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,929评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,048评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,203评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,960评论 2 355

推荐阅读更多精彩内容