Code: Select all
import pandas as pd
import numpy as np
dat = pd.DataFrame({'A' : [1,2,3,4,5], 'B' : ['2002-01-01', '2003-01-01', '2004-01-01', '2004-01-01', '2005-01-01']})
dat['B'] = pd.to_datetime(dat['B'])
dat['A'] = np.where(
dat['A'].isin([1,2]),
(dat['B'] + pd.DateOffset(months = 12)),
np.where(
dat['A'].isin([3,4]),
(dat['B'] + pd.DateOffset(months = 10)),
np.nan))
Code: Select all
Traceback (most recent call last):
File "", line 4, in 
numpy.exceptions.DTypePromotionError: The DType  could not be promoted by . This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (, )
 Mobile version
 Mobile version