Code for detour

MSL
Level 2
Code for detour

Hi folks, I want to replicate the functionality of detour using python.

Basically there are two datasets and I need to read both but I want the output of one of them based on the condition. Any idea how to replicate this function. 

Thankyou 

0 Kudos
3 Replies
Turribeach

I am not sure what's "the functionality of detour". And I can't really understand your requirement. You have two input datasets and one of the outputs is based on a condition. This sounds like a simple df filter in pandas but it also sounds like you are missing information to understand your requirement. 

0 Kudos
AshleyW
Dataiker

Hi @MSL , 

 

A complete shot in the dark here, but you may be able to use a Split recipe... I've done this in the past to create two separate branches in my Flow that reconnect later on in an 'either use branch A or use branch B' situation. Maybe this is what you're referring to with detour


The Split Recipe has a mode called 'define a filter for each output dataset' which lets you do just that. In this filter, I'd put whatever logic you need for your condition.

The 'true' goes to one output dataset, and 'false' goes to the other one. Depending on how your condition evaluates, all records in the input dataset will go to either one of the outputs.

You can then create two different branches in your Flow, only one of which will build with data.

At the end, use a stack recipe to bring the two branches back together. I've added a small photo to give you an idea of what a very simple version of this would look like.

splitbranch.png

Lmk if this helps!

Ashley

 
0 Kudos
Turribeach

Seems to be some way of branching in Alteryx:

https://www.thedataschool.co.uk/gregg-rimmer/using-detour-tool-alteryx/

 

0 Kudos