Data Cleaning Basics - Screen 13

Screen Link:

My Code:

What I expected to happen:

Replace this line with the code output you expected to get

What actually happened:

Replace this line with the actual output/error

I have tried to solve all the questions on screen 13

  1. Convert the price_euros column to a numeric dtype.
laptops["price_euros"] = laptops["price_euros"].str.replace(",",".").astype(float)
  1. Extract the screen resolution from the screen column.
screen = laptops["screen"]
screen_resolution = []
for scr in screen:
    screen_list = scr.split(" ")
    scr_res = screen_list[-1]
    screen_resolution.append(scr_res)
laptops["screen_resolution"] = screen_resolution

3) Extract the processor speed from the cpu column.

for cp in cpu:
    cp_list = cp.split()
    pro_speed = cp_list[-1]
    processor_speed.append(pro_speed)
laptops["processor_speed"] = processor_speed
laptops["processor_speed"] = laptops["processor_speed"].str.replace("GHz","")
laptops.rename({"processor_speed":"processor_speed_GHz"},axis=1,inplace=True)
  1. Are laptops made by Apple more expensive than those made by other manufacturers?
    I find that the Razor Laptops are the most expensive ones based on mean values of the Laptops with that manufaturer.

  2. What is the best value laptop with a screen size of 15" or more?
    Best Value laptop with screen size 15" or more is row 290, manufacturer- ACER, model_name - Chromebook C910-C2ST

  3. Which laptop has the most storage space?
    Most Storage Space laptops are with space 2 TB. There are 16 such laptops.

Please review and let me know the review comments.

@jugnu.arora

Please share a link to this screen.

Thanks!

Try to post the link to the screen and also try to follow the template

Please find the link to the screen as below:

Also my detailed code for 4, 5 and 6 point is as below:
4) Are laptops made by Apple more expensive than those made by other manufacturers?
I find that the Razor Laptops are the most expensive ones based on mean values of the Laptops with that manufacturer.

mean_price = {}
manufaturers = laptops[“manufacturer”].unique()
for mfr in manufaturers:
mfr_laptops = laptops[laptops[“manufacturer”] == mfr]
mean_price[mfr] = mfr_laptops[“price_euros”].mean()
mean_price_sorted = sorted(mean_price.items(), key=lambda x: x[1], reverse=True)

[(‘Razer’, 3346.1428571428573),
(‘LG’, 2099.0),
(‘MSI’, 1728.9081481481483),
(‘Google’, 1677.6666666666667),
(‘Microsoft’, 1612.3083333333334),
(‘Apple’, 1564.1985714285713),
(‘Huawei’, 1424.0),
(‘Samsung’, 1413.4444444444443),
(‘Toshiba’, 1267.8125),
(‘Dell’, 1186.06898989899),
(‘Xiaomi’, 1133.4625),
(‘Asus’, 1104.1693670886077),
(‘Lenovo’, 1086.3844444444446),
(‘HP’, 1067.7748540145985),
(‘Fujitsu’, 729.0),
(‘Acer’, 626.7758252427185),
(‘Chuwi’, 314.2966666666667),
(‘Mediacom’, 295.0),
(‘Vero’, 217.425)]

I find that the Razor Laptops are the most expensive ones based on mean values of the Laptops with that manufaturer.

  1. What is the best value laptop with a screen size of 15" or more?

laptops_15_or_greater = laptops[laptops[“screen_size_inches”] >= 15]
best_value_laptops = laptops_15_or_greater.sort_values(“price_euros”)

Best Value laptop with screen size 15" or more is row 290, manufacturer- ACER, model_name - Chromebook C910-C2ST

6)Which laptop has the most storage space?

laptops[“storage”] = laptops[“storage”].str.replace(“TB”,“000”).str.replace(“GB”,“”)
laptops.rename({“storage”:“storage_GB”},axis=1,inplace=True)
laptops[“first_storage”] = laptops[“storage_GB”].str.split(“+”).str[0].str.split().str[0].astype(int)
laptops[“second_storage”] = laptops[“storage_GB”].str.split(“+”).str[1].fillna(“0”).str.split().str[0].astype(int)
laptops[“total_storage_gb”] = laptops[“first_storage”] + laptops[“second_storage”]
max_storage_laptops = laptops.sort_values(“total_storage_gb”,ascending=False).iloc[0][[“manufacturer”,“model_name”,“total_storage_gb”]]

894
manufacturer MSI
model_name GS73VR Stealth
total_storage_gb 2512

1 Like