Created
May 16, 2019 14:41
-
-
Save L-Lewis/ba68c857917df96275a29da0c35f0776 to your computer and use it in GitHub Desktop.
Removing features for infrequent Airbnb amenities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Produces a list of amenity features where one category (true or false) contains fewer than 10% of listings | |
infrequent_amenities = [] | |
for col in df.iloc[:,41:].columns: | |
if df[col].sum() < len(df)/10: | |
infrequent_amenities.append(col) | |
print(infrequent_amenities) | |
# Dropping infrequent amenity features | |
df.drop(infrequent_amenities, axis=1, inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment