Question: Now write a function called clean _ data which takes a DataFrame as its only argument. This function should satisfy the following specification: It should

Now write a function called clean_data which takes a DataFrame as its only argument. This function should satisfy the following specification:
It should not modify the input DataFrame. Create a copy first, then modify it within the function.
It should remove all rows with missing values. This includes "bad" values that are not of type Missing.
It should remove invalid values in the :price and :area columns.
It should convert the :basicinfo and :extrainfo data into separate columns.
It should convert all columns to appropriate, concrete types. For example, :price should have elements of type Int.
The number of :bedrooms should be between 1 and 6, inclusive.
The number of :bedrooms, :bathrooms, and :stories should all be positive Ints.
The number of :bedrooms, :bathrooms, and :stories should all be reasonable values.
It should drop any redundant columns.
It should return a DataFrame satisfying the above criteria.
Hint: You can check your solution against cleandf by comparing sorted columns; i.e. sort(x)== sort(y) where x and y are columns from the two DataFrames being compared. Do this in Julia Version 1.10.0 with these packages:
import Pkg
Pkg.add("CSV")
Pkg.add("Plots")
using DataFrames, CSV, Plots, StatsPlots, DataFramesMeta
using CategoricalArrays, Statistics, StatsBase

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!