'AttributeError: 'str' object has no attribute 'astype'

sort new to python and pandas. Im sure im committing many python and programming crimes. This script worked on my personal pc but my work pc work run it. but my google-fu is weak and cannot find a solution to get it working or figure out what iv done wrong when it worked before. im getting this error

Traceback (most recent call last):
  File "A:\Python\doforms_data\Concept_script_working.pyw", line 1542, in <module>
    main()
  File "A:\Python\doforms_data\Concept_script_working.pyw", line 133, in main
    machine_refactory.apply(lambda x : x.astype(str)+' '+x.name) #
  File "C:\Users\agarth\AppData\Roaming\Python\Python38\site-packages\pandas\core\series.py", line 4045, in apply
    mapped = lib.map_infer(values, f, convert=convert_dtype)
  File "pandas/_libs/lib.pyx", line 2228, in pandas._libs.lib.map_infer
  File "A:\Python\doforms_data\Concept_script_working.pyw", line 133, in <lambda>
    machine_refactory.apply(lambda x : x.astype(str)+' '+x.name) #
    AttributeError: 'str' object has no attribute 'astype'

here is the code section.

   machine_refactory_loc=df.columns.get_loc(1629)
   machine_refactory=df.iloc[0:,(machine_refactory_loc):(machine_refactory_loc+2)]
   machine_refactory=machine_refactory.astype(str)
   machine_refactory.rename(columns = {1629:'Material'}, inplace = True) ## or Brick(1),Block(0)
   machine_refactory.rename(columns = {1630:'Roof'}, inplace = True) ## Flat(1),Arched(0)
   machine_refactory['Material'].replace('0','Block', inplace=True)
   machine_refactory['Material'].replace('1','Brick', inplace=True)
   machine_refactory['Roof'].replace('0',' - Arched Roof', inplace=True)
   machine_refactory['Roof'].replace('1',' - Flat Roof', inplace=True)
   machine_refactory=machine_refactory.astype(str)
   machine_refactory['Refractory (Blocked or Bricked) Cremator']=machine_refactory['Material']+ machine_refactory['Roof']
   machine_refactory=machine_refactory['Refractory (Blocked or Bricked) Cremator']
   machine_refactory.apply(lambda x : x.astype(str)+' '+x.name) #
   print(machine_refactory)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source