Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- file=pd.read_csv('amazon_co-ecommerce_sample.csv')
- file['product_name']=file['product_name'].astype(str)
- file['manufacturer']=file['manufacturer'].astype(str)
- file['price'] = file['price'].str.replace(r'[^\x00-\x7f]', '')
- file['price']=file['price'].fillna('0.00')
- file['number_available_in_stock']=file['number_available_in_stock'].str.replace(r'[^\x00-\x7f]', '')
- file['number_available_in_stock']=file['number_available_in_stock'].fillna('0 new')
- file['number_of_reviews']=file['number_of_reviews'].fillna(0)
- file['number_of_answered_questions']=file['number_of_answered_questions'].fillna(0)
- file['average_review_rating']=file['average_review_rating'].fillna(str('5.0 out of 5 stars'))
- file.to_csv('cleanfile.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement