怎么解决TypeError: unsupported operand type(s) for /: 'str' and 'int'

df['单位租金']=df['面积(㎡)']/df['价格(元/月)']

需要把面积与价格数据类型转换为float在进行计算,你有一个数据类型是字符串类型。修改如下,试试看行不

df['面积(㎡)'] = df['面积(㎡)'].astype('float32')
df['价格(元/月)'] = df['价格(元/月)'].astype('float32')
df['单位租金']=df['面积(㎡)']/df['价格(元/月)']

df是个列表吧,列表只能用数字去获取相应位置的元素。