You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a pandas Series containing lists. I wanted to replace empty lists with NaN. My first approach was using .replace, but that unexpectedly gave me a maximum recursion error.
I am using pandas 0.21.1 on Python 3.4, but other users had the same problem on 0.23
import numpy as np
import pandas as
ts = pd.Series([[1], [2, 3], [], [4]])
ts.replace([], np.nan)
RuntimeError: maximum recursion depth exceeded in comparison
I achieved the desired output using:
ts[ts.apply(len) == 0] = np.nan
but I don't understand the maximum recursion error