Icon

Challenge 13 - Onsite and Online Transactions - Solution

Onsite and Online Transactions

Your company keeps data related to online and onsite transactions in a tabular dataset with the following format:

Index Online Onsite

1 A.6777-01

2 7736-01

3 L-2210341175-00-000020

4 L-3210341175-00-000020

5 F5454

6 B_7736-01-00-000020

7 F5454 7736-01

In this challenge, you are asked to extract digits from the transactions (which are related to the bought products) given the following guidelines: (1) if the onsite transaction starts with “L”, then take its first 12 digits; otherwise, take its first 6 digits; and (2) if the onsite transaction has a missing value, then take the string from the online transaction.

What is the most efficient way to perform this task? For the example above, you should produce the following output column:

Product Codes

677701

773601

221034117500

221034117500

F5454

773601

773601

Nodes

Extensions

Links