pandas: convert multiple categories to dummies
<p>I have a table where each row can belong to multiple categories such as,</p>

<pre><code>test = pd.DataFrame({
            'name': ['a', 'b'],
            'category': [['cat1', 'cat2'],['cat1', 'cat3']]
    })
</code></pre>

<p>How can I convert each category to a dummy variable in such a way that the above table becomes,</p>

<pre><code>test_res = pd.DataFrame({
        'name': ['a', 'b'],
        'cat1': [1, 1],
        'cat2': [1, 0],
        'cat3': [0, 1]
    })
</code></pre>

<p>I tried <code>pd.get_dummies(test['category'])</code> but get the following error,</p>

<pre><code>TypeError: unhashable type: 'list'
</code></pre>