-2

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

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

return error

piRSquared
  • 265,629
  • 48
  • 427
  • 571

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
  • 4,847
  • 8
  • 37
  • 72
-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