I have a pandas dataframe with a column for years and one for months. How can I create a new date column based on these two (I can assume day = 15).
I tried the following:
import pandas as pd
import numpy as np
import datetime
df = pd.DataFrame()
df['year'] = np.arange(2000,2010)
df['mydate']= datetime.date( df['year'].apply(lambda x: int(x)) , 1 , 1)
but I get this error message:
df['mydate']= datetime.date( df['year'].apply(lambda x: int(x)) , 1 , 1) File "C:\Anaconda\lib\site-packages\pandas\core\series.py",line 77, in wrapper "cannot convert the series to {0}".format(str(converter))) TypeError: cannot convert the series to
which I don't understand because I explictly convert x to int.
Thanks!