Using Python Pandas and importing an Excel document, the following code is kicking back an error:
df['City'] = df['City'].astype(str)
df['Rent'] = np.where((df['City'].str.contains('ST PETERSBURG')) & (df['BedroomsTotal'] == 2), df['Rent'], df['LivingArea'] * df['Multiplier'])
The mentioned error is: AttributeError: 'DataFrame' object has no attribute 'str'
I added the top line to set the column to type string. They already should be strings since the column is a list of cities. Thoughts or suggestions on ways around this? Thanks.
.str
to do? – Jiří Baum