Skip to content

Instantly share code, notes, and snippets.

@erikgregorywebb
Last active July 18, 2018 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikgregorywebb/6197dd604713987af81e00c92321ae9b to your computer and use it in GitHub Desktop.
Save erikgregorywebb/6197dd604713987af81e00c92321ae9b to your computer and use it in GitHub Desktop.
def cleanLlistings(df):
# Split the location variable into location and days_online
df['location'], df['days_online'] = df['location'].str.split('|', 1).str
# Remove the dollar sign in price
df['price'] = df['price'].str.replace('$', '')
df['price'] = df['price'].str.replace(',', '')
# Convert from string to numeric
df['views'] = pd.to_numeric(df['views'])
df['favorites'] = pd.to_numeric(df['favorites'])
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment