ts = pd.Series({'a' : 1, 'b' : 2})
ids = ['a','c'] # 'c' is not in the index
# the result I want
np.array([ts.get(k, np.nan) for k in ids])
Is there a pandas native way to achieve this?
ts = pd.Series({'a' : 1, 'b' : 2})
ids = ['a','c'] # 'c' is not in the index
# the result I want
np.array([ts.get(k, np.nan) for k in ids])
Is there a pandas native way to achieve this?