How do I change integers in a column to NULL & another column to 0 or 0.0 if float?.
I don’t know how to handle this Python question and need guidance.
Save your time - order a paper!
Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlinesOrder Paper Now
Can someone help me change the integers in the column Country to the string NULL and as well as changing the column Order ID to 0.0 if it’s a float or 0 ?
So basically, if you find incorrect/missing data and its text type for that column, change it to NULL. If you find incorrect/missing data and its a number type for that column, change it to 0. (or 0.0 if its a float). Order ID (either missing OR won’t be a number) and Country (either missing OR will be a number as a string)
IT’S JUST FOR COLUMNS ORDER ID AND COUNTRY.
I’ve been trying to figure out how to do it and been struggling.
Here’s the original csv file(google spreadsheet): https://docs.google.com/spreadsheets/d/1H7Bpw3of5x…
I’ve also attached the csv and the original to the files as well.
Here’s my code:
import pandas as pd
import numpy as np
# Part 1: Cleaning the Data
print(“nPart 1: Cleaning the Data”)
df = pd.read_csv(‘Marvel_Mart_Sales_Project_Master.csv’)
df[‘Order Priority’].fillna(“NULL”, inplace=True)
df[‘Item Type’].fillna(“NULL”, inplace=True)
df[‘Order ID’] = pd.to_numeric(df[‘Order ID’],errors=’coerce’)
df[‘Order ID’].fillna(0, inplace=True)