Skip to content

Instantly share code, notes, and snippets.

@L-Lewis
Created May 16, 2019 14:41
Show Gist options
  • Save L-Lewis/ba68c857917df96275a29da0c35f0776 to your computer and use it in GitHub Desktop.
Save L-Lewis/ba68c857917df96275a29da0c35f0776 to your computer and use it in GitHub Desktop.
Removing features for infrequent Airbnb amenities
# 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