I have the following dataframe:
df:
y m d val
0 2013 10 1 33.5
1 2013 10 2 37.1
2 2013 10 3 25.9
3 2013 10 4 31.3
4 2013 10 5 35.3
5 2013 10 6 55.4
6 2013 10 7 29.5
7 2013 10 8 31.3
8 2013 10 9 27.7
9 2013 10 10 25.9
where y, m, d correspond to year, month and day respectively. I want to aggregate them and convert to a datetime.
df['date'] = 0
for v in df.index:
df['date'][v] = datetime.datetime(df.y[v], df.m[v], df.d[v])
I am wondering which is the best way to avoid that loop