-2

please see code and return
new to Python and really appreciate your help!

df['Height'] = df['Wall Top'] - df['Elevation']

return error

piRSquared
  • 285,575
  • 57
  • 475
  • 624

2 Answers2

2

The columns of your df are of different types. if you type:

df.dtypes

You'll see that one is str and one is float, or both are object type. You need to do this:

df['Height'] = df['Wall Top'].astype(float) - df['Elevation'].astype(float)

It should do the calculation you want.

Luis Miguel
  • 5,057
  • 8
  • 42
  • 75
-1

If you read the error, seems like a data type issue

df['Height'] = df['Wall Top'].astype(float) - df['Elevation'].astype(float)

or you can following existing post

zdeeb
  • 142
  • 9