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
  • 23,210
  • 7
  • 49
  • 68
bismo
  • 927
  • 8
  • 18

0 Answers0