Skip to content

Instantly share code, notes, and snippets.

@kunalrustagi08
Created May 6, 2020 16:09
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 kunalrustagi08/a362dc47c97f4a32c6c3537002e9ea4d to your computer and use it in GitHub Desktop.
Save kunalrustagi08/a362dc47c97f4a32c6c3537002e9ea4d to your computer and use it in GitHub Desktop.
import pandas as pd
col_dict = {'title':titles, 'price':prices, 'rating':ratings}
book_store = pd.DataFrame(col_dict)
print(book_store.head())
print(book_store.dtypes)
book_store['price'] = book_store['price'].apply(lambda x : float(x[2:]))
number_mapping = {'One':1,'Two':2,'Three':3,'Four':4,'Five':5}
book_store['rating'] = book_store['rating'].apply(lambda x : number_mapping.get(x))
print(book_store.head())
print(book_store.dtypes)
book_store.to_csv('book_store.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment