0

I have the following df

   age
0   6
1   20
2   80

I want to create another column that inserts age in the middle of a string. I tried the following, but I did not get my desired output.

df['x'] = 'They are' + str(age) + 'years old.'

This is my desired output

   age            x
0   6   'They are 6 years old'
1   20  'They are 20 years old'
2   80  'They are 80 years old'

wjandrea
  • 28,235
  • 9
  • 60
  • 81
bismo
  • 1,257
  • 1
  • 16
  • 36

0 Answers0