All problems
Feature Crossing
Problem
Cross two categorical features by concatenating each pair as 'a_b' strings.
Return the crossed list; empty input returns [].
Hint
Convert both values to strings and join them with an underscore.
Test cases
case 1
in: [["red","blue"],["S","M"]]
expected: ["red_S","blue_M"]
case 2
in: [[1,2],[3,4]]
expected: ["1_3","2_4"]
case 3
in: [["x"],["y"]]
expected: ["x_y"]
case 4
in: [[],[]]
expected: []
Starter codePython
def feature_cross(a, b):
# Your code here
pass4 test cases · run your code against them in the editor