Reputation: 1036
I have year and month column in my pandas data frame and i want to concatenate them by as a string so that i can convert them into datetime.
df.info() gives
Data columns (total 3 columns):
years 372 non-null object
months 372 non-null object
windSpeedM 371 non-null float64
and the data looks like
years month windSpeedM
1985 1 0.4
i am trying this
ff2['date'] = ff2['years']+'-'+ff2['months']+'-'+'01'
i am getting an error
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('S21') dtype('S21') dtype('S21')
Upvotes: 1
Views: 11506
Reputation: 944
ff2['date'] = ff2['years'].map(str)+'-'+ff2['months'].map(str)+'-'+'01'
Upvotes: 3