Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Code Question 1: Convert all columns that store categorical values to numerical values. Hint, store the unique values of a particular column in a

Python Code

Question 1: Convert all columns that store categorical values to numerical values. Hint, store the unique values of a particular column in a list and replace the unique value with its index. Store your results in a new dataframe called DF2.

Question 2:

1-Define a new dataframe called DF3 that has a copy of DF2. Convert ordinal values to numarical values.

2-Define a new dataframe called DF4 that has a copy of DF2. Drop the columns that store ordinal values.

3-Define a new dataframe called DF5 that has a copy of df. Drop all columns that contain non-numeric values.

Question 3:

Split DF4 into 70% training and 30% testing data.

image text in transcribed

car price body mileage engVengType registration year model drive 0 Ford 15500.0 Crossover 68 2.5 Gas yes 2010 Kuga full 1 sedan 173 1.8 Gas yes 2011 E-Class rear 2 other 135 5.5 Petrol yes 2008 CL 550 rear Mercedes-Benz 20500.0 Mercedes-Benz 35000.0 Mercedes-Benz 17800.0 Mercedes-Benz 33000.0 3 van 162 1.8 Diesel yes 2012 B 180 front 4 vagon 91 NaN Other yes 2013 E-Class NaN 140 2.0 Gas yes 2011 Tucson front 9571 Hyundai 14500.0 crossover 9572 Volkswagen 2200.0 vagon 9573 Mercedes-Benz 18500.0 crossover 150 1.6 Petrol yes 1986 Passat B2 front 180 3.5 Petrol yes 2008 ML 350 full 9574 Lexus 16999.0 sedan 150 3.5 Gas yes 2008 ES 350 front 9575 Audi 22500.0 other 71 3.6 Petrol yes 2007 Q7 full 9576 rows x 10 columns

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions