python - numpy.where: TypeError: invalid type promotion -
know there other questions same error name, yet none of them match np.where statement, , couldn't find answer problem in them
made pandas dataframe called data , created series out of called dates, is:
dates= pd.to_datetime(pd.to_timedelta(data.a_date, unit= 'd') + pd.datetime(1960,1,1), errors= 'coerse') i need clear of dates because not match indicator of them in data, tried adjust while keeping indexes correct using numpy.where,
yet had gotten error:
--------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-18-2b83ed2b2468> in <module>() ----> 1 np.where(((dates.notnull()) & (data.a_ind == 0)), np.nan, dates) typeerror: invalid type promotion
the documentation of np.where(cond, x, y) says second , third arguments - x , y - need array or array_like. also, believe x , y must of same shape.
your x scalar (np.nan) , y array_like object (dates). maybe that's problem.
Comments
Post a Comment