Here is my Code:
dfnew=pd.DataFrame({ 'year': [2015,2016],
'month': [10, 12],
'day': [25,31]})
print(dfnew)
def calc(yy,n):
if yy==2016:
return yy*2*n
else:
return yy
dfnew['nv']=map(calc, dfnew['year'],2)
print(dfnew['nv'])
How I can get this code running without error? I want the function to be applied only on the 'Year' column of the dataframe for all rows and store output on a new column named 'nv' of the same dataframe.