replace empty list with NaN in pandas dataframe : <p>I'm trying to replace some empty list in my data with a NaN values. But how to represent an empty list in the expression?</p>

<pre><code>import numpy as np
import pandas as pd
d = pd.DataFrame({'x' : [[1,2,3], [1,2], ["text"], []], 'y' : [1,2,3,4]})
d

    x           y
0   [1, 2, 3]   1
1   [1, 2]      2
2   [text]      3
3   []          4



d.loc[d['x'] == [],['x']] = d.loc[d['x'] == [],'x'].apply(lambda x: np.nan)
d

ValueError: Arrays were different lengths: 4 vs 0
</code></pre>

<p>And, I want to select <code>[text]</code> by using <code>d[d['x'] == ["text"]]</code> with a <code>ValueError: Arrays were different lengths: 4 vs 1</code> error, but select <code>3</code> by using <code>d[d['y'] == 3]</code> is correct. Why?</p>
