ISEbd-31_Musatkina_K_Y_mii/lab1.ipynb

1.3 MiB
Raw Blame History

загрузка и сохранение данных

In [3]:
import pandas as pd
df = pd.read_csv("mobile_phone_price_prediction.csv", index_col="Name")
df.to_csv("test.csv")

получение сведений о датафрейме с данными

In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'>
Index: 1370 entries, Samsung Galaxy F14 5G to TCL Trifold
Data columns (total 17 columns):
 #   Column             Non-Null Count  Dtype  
---  ------             --------------  -----  
 0   Unnamed: 0         1370 non-null   int64  
 1   Rating             1370 non-null   float64
 2   Spec_score         1370 non-null   int64  
 3   No_of_sim          1370 non-null   object 
 4   Ram                1370 non-null   object 
 5   Battery            1370 non-null   object 
 6   Display            1370 non-null   object 
 7   Camera             1370 non-null   object 
 8   External_Memory    1370 non-null   object 
 9   Android_version    927 non-null    object 
 10  Price              1370 non-null   object 
 11  company            1370 non-null   object 
 12  Inbuilt_memory     1351 non-null   object 
 13  fast_charging      1281 non-null   object 
 14  Screen_resolution  1368 non-null   object 
 15  Processor          1342 non-null   object 
 16  Processor_name     1370 non-null   object 
dtypes: float64(1), int64(2), object(14)
memory usage: 192.7+ KB

получение сведений о колонках датафрейма

In [5]:
print(df.columns)
Index(['Unnamed: 0', 'Rating', 'Spec_score', 'No_of_sim', 'Ram', 'Battery',
       'Display', 'Camera', 'External_Memory', 'Android_version', 'Price',
       'company', 'Inbuilt_memory', 'fast_charging', 'Screen_resolution',
       'Processor', 'Processor_name'],
      dtype='object')

вывод строк и столбцов из датафрейма

In [9]:
df[["Rating", "Spec_score", "No_of_sim"]]
Out[9]:
Rating Spec_score No_of_sim
Name
Samsung Galaxy F14 5G 4.65 68 Dual Sim, 3G, 4G, 5G, VoLTE,
Samsung Galaxy A11 4.20 63 Dual Sim, 3G, 4G, VoLTE,
Samsung Galaxy A13 4.30 75 Dual Sim, 3G, 4G, VoLTE,
Samsung Galaxy F23 4.10 73 Dual Sim, 3G, 4G, VoLTE,
Samsung Galaxy A03s (4GB RAM + 64GB) 4.10 69 Dual Sim, 3G, 4G, VoLTE,
... ... ... ...
TCL 40R 4.05 75 Dual Sim, 3G, 4G, 5G, VoLTE,
TCL 50 XL NxtPaper 5G 4.10 80 Dual Sim, 3G, 4G, VoLTE,
TCL 50 XE NxtPaper 5G 4.00 80 Dual Sim, 3G, 4G, 5G, VoLTE,
TCL 40 NxtPaper 5G 4.50 79 Dual Sim, 3G, 4G, 5G, VoLTE,
TCL Trifold 4.65 93 Dual Sim, 3G, 4G, 5G, VoLTE, Vo5G,

1370 rows × 3 columns

вывод первых строк

In [11]:
print(df.head())
                                      Unnamed: 0  Rating  Spec_score  \
Name                                                                   
Samsung Galaxy F14 5G                          0    4.65          68   
Samsung Galaxy A11                             1    4.20          63   
Samsung Galaxy A13                             2    4.30          75   
Samsung Galaxy F23                             3    4.10          73   
Samsung Galaxy A03s (4GB RAM + 64GB)           4    4.10          69   

                                                          No_of_sim       Ram  \
Name                                                                            
Samsung Galaxy F14 5G                 Dual Sim, 3G, 4G, 5G, VoLTE,   4 GB RAM   
Samsung Galaxy A11                        Dual Sim, 3G, 4G, VoLTE,   2 GB RAM   
Samsung Galaxy A13                        Dual Sim, 3G, 4G, VoLTE,   4 GB RAM   
Samsung Galaxy F23                        Dual Sim, 3G, 4G, VoLTE,   4 GB RAM   
Samsung Galaxy A03s (4GB RAM + 64GB)      Dual Sim, 3G, 4G, VoLTE,   4 GB RAM   

                                                Battery     Display  \
Name                                                                  
Samsung Galaxy F14 5G                 6000 mAh Battery   6.6 inches   
Samsung Galaxy A11                    4000 mAh Battery   6.4 inches   
Samsung Galaxy A13                    5000 mAh Battery   6.6 inches   
Samsung Galaxy F23                     6000 mAh Battery  6.4 inches   
Samsung Galaxy A03s (4GB RAM + 64GB)  5000 mAh Battery   6.5 inches   

                                                                                 Camera  \
Name                                                                                      
Samsung Galaxy F14 5G                   50 MP + 2 MP Dual Rear &amp; 13 MP Front Camera   
Samsung Galaxy A11                    13 MP + 5 MP + 2 MP Triple Rear &amp; 8 MP Fro...   
Samsung Galaxy A13                              50 MP Quad Rear &amp; 8 MP Front Camera   
Samsung Galaxy F23                             48 MP Quad Rear &amp; 13 MP Front Camera   
Samsung Galaxy A03s (4GB RAM + 64GB)  13 MP + 2 MP + 2 MP Triple Rear &amp; 5 MP Fro...   

                                                         External_Memory  \
Name                                                                       
Samsung Galaxy F14 5G                   Memory Card Supported, upto 1 TB   
Samsung Galaxy A11                    Memory Card Supported, upto 512 GB   
Samsung Galaxy A13                      Memory Card Supported, upto 1 TB   
Samsung Galaxy F23                      Memory Card Supported, upto 1 TB   
Samsung Galaxy A03s (4GB RAM + 64GB)    Memory Card Supported, upto 1 TB   

                                     Android_version   Price  company  \
Name                                                                    
Samsung Galaxy F14 5G                             13   9,999  Samsung   
Samsung Galaxy A11                                10   9,990  Samsung   
Samsung Galaxy A13                                12  11,999  Samsung   
Samsung Galaxy F23                                12  11,999  Samsung   
Samsung Galaxy A03s (4GB RAM + 64GB)              11  11,999  Samsung   

                                       Inbuilt_memory       fast_charging  \
Name                                                                        
Samsung Galaxy F14 5G                  128 GB inbuilt   25W Fast Charging   
Samsung Galaxy A11                      32 GB inbuilt   15W Fast Charging   
Samsung Galaxy A13                      64 GB inbuilt   25W Fast Charging   
Samsung Galaxy F23                      64 GB inbuilt                 NaN   
Samsung Galaxy A03s (4GB RAM + 64GB)    64 GB inbuilt   15W Fast Charging   

                                                                  Screen_resolution  \
Name                                                                                  
Samsung Galaxy F14 5G                  2408 x 1080 px Display with Water Drop Notch   
Samsung Galaxy A11                            720 x 1560 px Display with Punch Hole   
Samsung Galaxy A13                     1080 x 2408 px Display with Water Drop Notch   
Samsung Galaxy F23                                                    720 x 1600 px   
Samsung Galaxy A03s (4GB RAM + 64GB)    720 x 1600 px Display with Water Drop Notch   

                                                 Processor Processor_name  
Name                                                                       
Samsung Galaxy F14 5G                  Octa Core Processor    Exynos 1330  
Samsung Galaxy A11                       1.8 GHz Processor      Octa Core  
Samsung Galaxy A13                         2 GHz Processor      Octa Core  
Samsung Galaxy F23                               Octa Core      Helio G88  
Samsung Galaxy A03s (4GB RAM + 64GB)             Octa Core      Helio P35  

вывод строк по условию

In [33]:
df[["Rating"]]
Out[33]:
Rating
Name
Samsung Galaxy F14 5G 4.65
Samsung Galaxy A11 4.20
Samsung Galaxy A13 4.30
Samsung Galaxy F23 4.10
Samsung Galaxy A03s (4GB RAM + 64GB) 4.10
... ...
TCL 40R 4.05
TCL 50 XL NxtPaper 5G 4.10
TCL 50 XE NxtPaper 5G 4.00
TCL 40 NxtPaper 5G 4.50
TCL Trifold 4.65

1370 rows × 1 columns

In [35]:
df[df ["Rating"] < 4.00 ]
Out[35]:
Unnamed: 0 Rating Spec_score No_of_sim Ram Battery Display Camera External_Memory Android_version Price company Inbuilt_memory fast_charging Screen_resolution Processor Processor_name
Name
Vivo Y21T 118 3.95 74 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.51 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card Supported, upto 1 TB 11 NaN Vivo 128 GB inbuilt 18W Fast Charging 1600 x 720 px Octa Core Snapdragon 680
Vivo Y66 125 3.75 53 Dual Sim, 3G, 4G, VoLTE, 3 GB RAM 3000 mAh Battery 5.5 inches 13 MP Rear &amp; 16 MP Front Camera Memory Card Supported, upto 128 GB 6.0 (Marshmallow) NaN Vivo 32 GB inbuilt NaN 720 x 1280 px Display Octa Core Snapdragon MSM8937
Vivo V23 Pro 5G 146 3.90 85 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 4300 mAh Battery 6.56 inches 108 MP + 8 MP + 2 MP Triple Rear &amp; 50 MP +... Memory Card Not Supported 12 NaN Vivo 128 GB inbuilt 44W Fast Charging 1080 x 2376 px Octa Core Dimensity 1200
Realme 8i 229 3.95 74 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 16 MP Fr... Memory Card Supported, upto 256 GB 11 NaN Realme 64 GB inbuilt 18W Fast Charging 1080 x 2412 px Octa Core Helio G96
Realme 9 5G 259 3.95 75 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.5 inches 48 MP + 2 MP + 2 MP Triple Rear &amp; 16 MP Fr... Memory Card Supported, upto 1 TB 11 NaN Realme 64 GB inbuilt 18W Fast Charging 1080 x 2400 px Octa Core Dimensity 810 5G
Realme 6i (6GB RAM + 64GB) 264 3.85 76 Dual Sim, 3G, 4G, VoLTE, Helio G90T 6 GB RAM, 64 GB inbuilt 4300 mAh Battery with 30W Fast Charging 6.5 inches, 1080 x 2400 px, 90 Hz Display with... 48 MP Quad Rear &amp; 16 MP Front Camera NaN NaN Realme Octa Core NaN NaN NaN No Wifi
Poco M4 Pro 5G 502 3.95 76 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 8 MP Dual Rear &amp; 16 MP Front Camera Memory Card (Hybrid), upto 1 TB 11 NaN Poco 64 GB inbuilt 33W Fast Charging 1080 x 2400 px Octa Core Dimensity 810 5G
Poco F4 5G 530 3.95 82 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 4500 mAh Battery 6.67 inches 64 MP + 8 MP + 2 MP Triple Rear &amp; 20 MP Fr... Android v12 NaN NaN Poco 128 GB inbuilt 67W Fast Charging 1080 x 2400 px Octa Core Snapdragon 870
Nothing Phone 1 619 3.95 85 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 4500 mAh Battery 6.55 inches 50 MP + 50 MP Dual Rear &amp; 16 MP Front Camera Android v12 NaN NaN Nothing 128 GB inbuilt 33W Fast Charging 1080 x 2400 px Octa Core Snapdragon 778G Plus
Samsung Galaxy M34 5G 738 3.95 82 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 6000 mAh Battery 6.5 inches 50 MP + 8 MP + 2 MP Triple Rear &amp; 13 MP Fr... Memory Card (Hybrid), upto 1 TB 13 NaN Samsung 128 GB inbuilt 25W Fast Charging 1080 x 2340 px Octa Core Exynos 1280
Realme Narzo 50 874 3.95 74 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 16 MP Fr... Memory Card Supported, upto 256 GB 11 NaN Realme 64 GB inbuilt 33W Fast Charging 1080 x 2412 px Octa Core Helio G96
Motorola Moto G 5G 1002 3.90 82 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.67 inches 48 MP + 8 MP + 2 MP Triple Rear &amp; 16 MP Fr... Memory Card (Hybrid), upto 1 TB 10 NaN Motorola 128 GB inbuilt 20W Fast Charging 1080 x 2400 px Display with Punch Hole Octa Core Snapdragon 750G
Xiaomi Redmi Note 12 5G 1148 3.90 77 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.67 inches 48 MP + 8 MP + 2 MP Triple Rear &amp; 13 MP Fr... Memory Card (Hybrid), upto 1 TB 12 NaN Xiaomi 128 GB inbuilt 33W Fast Charging 1080 x 2400 px Octa Core Snapdragon 4 Gen 1

группировка и агрегация данных в датафрейме

In [36]:
group = df.groupby(["Display"])["Rating"].mean()
group.to_frame()
Out[36]:
Rating
Display
10 inches 4.650000
12.1 inches 4.400000
4.5 inches 4.000000
4300 mAh Battery with 30W Fast Charging 3.850000
48 MP + 5 MP + 2 MP Triple Rear &amp; 8 MP Front Camera 4.550000
... ...
8 inches 4.266667
8.02 inches 4.325000
8.03 inches 4.308333
8.2 inches 4.100000
8.3 inches 4.450000

89 rows × 1 columns

сортировка данных в датафрейме

In [37]:
sorted_df = df.sort_values(by="Rating", ascending=True)
sorted_df
Out[37]:
Unnamed: 0 Rating Spec_score No_of_sim Ram Battery Display Camera External_Memory Android_version Price company Inbuilt_memory fast_charging Screen_resolution Processor Processor_name
Name
Vivo Y66 125 3.75 53 Dual Sim, 3G, 4G, VoLTE, 3 GB RAM 3000 mAh Battery 5.5 inches 13 MP Rear &amp; 16 MP Front Camera Memory Card Supported, upto 128 GB 6.0 (Marshmallow) NaN Vivo 32 GB inbuilt NaN 720 x 1280 px Display Octa Core Snapdragon MSM8937
Realme 6i (6GB RAM + 64GB) 264 3.85 76 Dual Sim, 3G, 4G, VoLTE, Helio G90T 6 GB RAM, 64 GB inbuilt 4300 mAh Battery with 30W Fast Charging 6.5 inches, 1080 x 2400 px, 90 Hz Display with... 48 MP Quad Rear &amp; 16 MP Front Camera NaN NaN Realme Octa Core NaN NaN NaN No Wifi
Motorola Moto G 5G 1002 3.90 82 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.67 inches 48 MP + 8 MP + 2 MP Triple Rear &amp; 16 MP Fr... Memory Card (Hybrid), upto 1 TB 10 NaN Motorola 128 GB inbuilt 20W Fast Charging 1080 x 2400 px Display with Punch Hole Octa Core Snapdragon 750G
Vivo V23 Pro 5G 146 3.90 85 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 4300 mAh Battery 6.56 inches 108 MP + 8 MP + 2 MP Triple Rear &amp; 50 MP +... Memory Card Not Supported 12 NaN Vivo 128 GB inbuilt 44W Fast Charging 1080 x 2376 px Octa Core Dimensity 1200
Xiaomi Redmi Note 12 5G 1148 3.90 77 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.67 inches 48 MP + 8 MP + 2 MP Triple Rear &amp; 13 MP Fr... Memory Card (Hybrid), upto 1 TB 12 NaN Xiaomi 128 GB inbuilt 33W Fast Charging 1080 x 2400 px Octa Core Snapdragon 4 Gen 1
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Vivo V30e (8GB RAM + 256GB) 145 4.75 86 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 5500 mAh Battery 6.78 inches 50 MP + 8 MP Dual Rear &amp; 50 MP Front Camera Memory Card (Hybrid) 14 NaN Vivo 256 GB inbuilt 44W Fast Charging 1080 x 2400 px Octa Core Snapdragon 6 Gen1
Realme 11 901 4.75 83 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 5000 mAh Battery 6.72 inches 108 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card Supported, upto 1 TB 13 NaN Realme 128 GB inbuilt 67W Fast Charging 1080 x 2400 px Octa Core Dimensity 6100 Plus
Samsung Galaxy A15 5G 24 4.75 81 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 5000 mAh Battery 6.5 inches 50 MP + 5 MP + 2 MP Triple Rear &amp; 13 MP Fr... Memory Card (Hybrid), upto 1 TB 14 NaN Samsung 128 GB inbuilt 25W Fast Charging 1080 x 2340 px Octa Core Dimensity 6100 Plus
Samsung Galaxy F25 5G 27 4.75 76 Dual Sim, 3G, 4G, 5G, VoLTE, 8 GB RAM 5000 mAh Battery 6.67 inches 64 MP + 8 MP + 2 MP Triple Rear &amp; 16 MP Fr... Memory Card Supported, upto 1 TB 14 NaN Samsung 128 GB inbuilt 30W Fast Charging 1080 x 2408 px NaN Octa Core Processor
Samsung Galaxy A14 5G (6GB RAM + 128GB) 18 4.75 79 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 13 MP Fr... Memory Card Supported, upto 1 TB 13 NaN Samsung 128 GB inbuilt 15W Fast Charging 1080 x 2408 px Octa Core Exynos 1330

1370 rows × 17 columns

удаление строк/столбцов

In [38]:
df_dropped_columns = df.drop(columns=["Android_version", "company"])
df_dropped_columns
Out[38]:
Unnamed: 0 Rating Spec_score No_of_sim Ram Battery Display Camera External_Memory Price Inbuilt_memory fast_charging Screen_resolution Processor Processor_name
Name
Samsung Galaxy F14 5G 0 4.65 68 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 6000 mAh Battery 6.6 inches 50 MP + 2 MP Dual Rear &amp; 13 MP Front Camera Memory Card Supported, upto 1 TB NaN 128 GB inbuilt 25W Fast Charging 2408 x 1080 px Display with Water Drop Notch Octa Core Processor Exynos 1330
Samsung Galaxy A11 1 4.20 63 Dual Sim, 3G, 4G, VoLTE, 2 GB RAM 4000 mAh Battery 6.4 inches 13 MP + 5 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card Supported, upto 512 GB NaN 32 GB inbuilt 15W Fast Charging 720 x 1560 px Display with Punch Hole 1.8 GHz Processor Octa Core
Samsung Galaxy A13 2 4.30 75 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP Quad Rear &amp; 8 MP Front Camera Memory Card Supported, upto 1 TB NaN 64 GB inbuilt 25W Fast Charging 1080 x 2408 px Display with Water Drop Notch 2 GHz Processor Octa Core
Samsung Galaxy F23 3 4.10 73 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 6000 mAh Battery 6.4 inches 48 MP Quad Rear &amp; 13 MP Front Camera Memory Card Supported, upto 1 TB NaN 64 GB inbuilt NaN 720 x 1600 px Octa Core Helio G88
Samsung Galaxy A03s (4GB RAM + 64GB) 4 4.10 69 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.5 inches 13 MP + 2 MP + 2 MP Triple Rear &amp; 5 MP Fro... Memory Card Supported, upto 1 TB NaN 64 GB inbuilt 15W Fast Charging 720 x 1600 px Display with Water Drop Notch Octa Core Helio P35
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
TCL 40R 1365 4.05 75 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card (Hybrid) NaN 64 GB inbuilt 15W Fast Charging 720 x 1612 px Octa Core Dimensity 700 5G
TCL 50 XL NxtPaper 5G 1366 4.10 80 Dual Sim, 3G, 4G, VoLTE, 8 GB RAM 5000 mAh Battery 6.8 inches 50 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card (Hybrid) NaN 128 GB inbuilt 33W Fast Charging 1200 x 2400 px Octa Core Dimensity 7050
TCL 50 XE NxtPaper 5G 1367 4.00 80 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card Supported, upto 1 TB NaN 256 GB inbuilt 18W Fast Charging 720 x 1612 px Octa Core Dimensity 6080
TCL 40 NxtPaper 5G 1368 4.50 79 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card Supported, upto 1 TB NaN 256 GB inbuilt 15W Fast Charging 720 x 1612 px Octa Core Dimensity 6020
TCL Trifold 1369 4.65 93 Dual Sim, 3G, 4G, 5G, VoLTE, Vo5G, 12 GB RAM 4600 mAh Battery 10 inches Foldable Display, Dual Display 50 MP + 48 MP + 8 MP Triple Rear &amp; 32 MP F... NaN 256 GB inbuilt 67W Fast Charging 1916 x 2160 px Octa Core Snapdragon 8 Gen2

1370 rows × 15 columns

In [39]:
df_dropped_rows = df.drop(df.index[[0, 1]], inplace=True)
df_dropped_rows = df.reset_index(drop=True)
df_dropped_rows
Out[39]:
Unnamed: 0 Rating Spec_score No_of_sim Ram Battery Display Camera External_Memory Android_version Price company Inbuilt_memory fast_charging Screen_resolution Processor Processor_name
0 2 4.30 75 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP Quad Rear &amp; 8 MP Front Camera Memory Card Supported, upto 1 TB 12 NaN Samsung 64 GB inbuilt 25W Fast Charging 1080 x 2408 px Display with Water Drop Notch 2 GHz Processor Octa Core
1 3 4.10 73 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 6000 mAh Battery 6.4 inches 48 MP Quad Rear &amp; 13 MP Front Camera Memory Card Supported, upto 1 TB 12 NaN Samsung 64 GB inbuilt NaN 720 x 1600 px Octa Core Helio G88
2 4 4.10 69 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.5 inches 13 MP + 2 MP + 2 MP Triple Rear &amp; 5 MP Fro... Memory Card Supported, upto 1 TB 11 NaN Samsung 64 GB inbuilt 15W Fast Charging 720 x 1600 px Display with Water Drop Notch Octa Core Helio P35
3 5 4.40 75 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.5 inches 50 MP + 2 MP Dual Rear &amp; 5 MP Front Camera Memory Card Supported, upto 1 TB 12 NaN Samsung 128 GB inbuilt 15W Fast Charging 720 x 1600 px Octa Core Dimensity 700
4 6 4.10 76 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 6000 mAh Battery 6.4 inches 48 MP + 8 MP + 5 MP Triple Rear &amp; 20 MP Fr... Memory Card Supported, upto 512 GB 11 NaN Samsung 64 GB inbuilt 15W Fast Charging 1080 x 2340 px Display with Water Drop Notch Octa Core Exynos 9611
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1363 1365 4.05 75 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card (Hybrid) 12 NaN TCL 64 GB inbuilt 15W Fast Charging 720 x 1612 px Octa Core Dimensity 700 5G
1364 1366 4.10 80 Dual Sim, 3G, 4G, VoLTE, 8 GB RAM 5000 mAh Battery 6.8 inches 50 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card (Hybrid) 14 NaN TCL 128 GB inbuilt 33W Fast Charging 1200 x 2400 px Octa Core Dimensity 7050
1365 1367 4.00 80 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card Supported, upto 1 TB 13 NaN TCL 256 GB inbuilt 18W Fast Charging 720 x 1612 px Octa Core Dimensity 6080
1366 1368 4.50 79 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card Supported, upto 1 TB 13 NaN TCL 256 GB inbuilt 15W Fast Charging 720 x 1612 px Octa Core Dimensity 6020
1367 1369 4.65 93 Dual Sim, 3G, 4G, 5G, VoLTE, Vo5G, 12 GB RAM 4600 mAh Battery 10 inches Foldable Display, Dual Display 50 MP + 48 MP + 8 MP Triple Rear &amp; 32 MP F... 13 NaN TCL 256 GB inbuilt 67W Fast Charging 1916 x 2160 px Octa Core Snapdragon 8 Gen2

1368 rows × 17 columns

создание новых столбцов на основе данных из существующих столбцов

In [52]:
#df_dropped_columns = df.drop(columns=["Price_Rating", "Price_per_GB_RAM"])
#df_dropped_columns
df["Total_Storage_GB"] = df["Inbuilt_memory"] + df["External_Memory"]
df
Out[52]:
Unnamed: 0 Rating Spec_score No_of_sim Ram Battery Display Camera External_Memory Android_version ... fast_charging Screen_resolution Processor Processor_name Price_per_GB_RAM Price_Rating Ram_GB Battery_mAh Screen_Type Total_Storage_GB
Name
Samsung Galaxy A13 2 4.30 75 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP Quad Rear &amp; 8 MP Front Camera Memory Card Supported, upto 1 TB 12 ... 25W Fast Charging 1080 x 2408 px Display with Water Drop Notch 2 GHz Processor Octa Core NaN NaN 4 5000 2408 64 GB inbuiltMemory Card Supported, upto 1 TB
Samsung Galaxy F23 3 4.10 73 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 6000 mAh Battery 6.4 inches 48 MP Quad Rear &amp; 13 MP Front Camera Memory Card Supported, upto 1 TB 12 ... NaN 720 x 1600 px Octa Core Helio G88 NaN NaN 4 6000 1600 64 GB inbuiltMemory Card Supported, upto 1 TB
Samsung Galaxy A03s (4GB RAM + 64GB) 4 4.10 69 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 5000 mAh Battery 6.5 inches 13 MP + 2 MP + 2 MP Triple Rear &amp; 5 MP Fro... Memory Card Supported, upto 1 TB 11 ... 15W Fast Charging 720 x 1600 px Display with Water Drop Notch Octa Core Helio P35 NaN NaN 4 5000 1600 64 GB inbuiltMemory Card Supported, upto 1 TB
Samsung Galaxy M13 5G 5 4.40 75 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.5 inches 50 MP + 2 MP Dual Rear &amp; 5 MP Front Camera Memory Card Supported, upto 1 TB 12 ... 15W Fast Charging 720 x 1600 px Octa Core Dimensity 700 NaN NaN 6 5000 1600 128 GB inbuiltMemory Card Supported, upto 1 TB
Samsung Galaxy M21 2021 6 4.10 76 Dual Sim, 3G, 4G, VoLTE, 4 GB RAM 6000 mAh Battery 6.4 inches 48 MP + 8 MP + 5 MP Triple Rear &amp; 20 MP Fr... Memory Card Supported, upto 512 GB 11 ... 15W Fast Charging 1080 x 2340 px Display with Water Drop Notch Octa Core Exynos 9611 NaN NaN 4 6000 2340 64 GB inbuiltMemory Card Supported, upto 512 GB
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
TCL 40R 1365 4.05 75 Dual Sim, 3G, 4G, 5G, VoLTE, 4 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card (Hybrid) 12 ... 15W Fast Charging 720 x 1612 px Octa Core Dimensity 700 5G NaN NaN 4 5000 1612 64 GB inbuiltMemory Card (Hybrid)
TCL 50 XL NxtPaper 5G 1366 4.10 80 Dual Sim, 3G, 4G, VoLTE, 8 GB RAM 5000 mAh Battery 6.8 inches 50 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card (Hybrid) 14 ... 33W Fast Charging 1200 x 2400 px Octa Core Dimensity 7050 NaN NaN 8 5000 2400 128 GB inbuiltMemory Card (Hybrid)
TCL 50 XE NxtPaper 5G 1367 4.00 80 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP Dual Rear &amp; 16 MP Front Camera Memory Card Supported, upto 1 TB 13 ... 18W Fast Charging 720 x 1612 px Octa Core Dimensity 6080 NaN NaN 6 5000 1612 256 GB inbuiltMemory Card Supported, upto 1 TB
TCL 40 NxtPaper 5G 1368 4.50 79 Dual Sim, 3G, 4G, 5G, VoLTE, 6 GB RAM 5000 mAh Battery 6.6 inches 50 MP + 2 MP + 2 MP Triple Rear &amp; 8 MP Fro... Memory Card Supported, upto 1 TB 13 ... 15W Fast Charging 720 x 1612 px Octa Core Dimensity 6020 NaN NaN 6 5000 1612 256 GB inbuiltMemory Card Supported, upto 1 TB
TCL Trifold 1369 4.65 93 Dual Sim, 3G, 4G, 5G, VoLTE, Vo5G, 12 GB RAM 4600 mAh Battery 10 inches Foldable Display, Dual Display 50 MP + 48 MP + 8 MP Triple Rear &amp; 32 MP F... 13 ... 67W Fast Charging 1916 x 2160 px Octa Core Snapdragon 8 Gen2 NaN NaN 12 4600 2160 256 GB inbuilt50 MP + 48 MP + 8 MP Triple Rea...

1368 rows × 23 columns

Удаление строк с пустыми значениями

In [53]:
print(df.isna().sum())
Unnamed: 0              0
Rating                  0
Spec_score              0
No_of_sim               0
Ram                     0
Battery                 0
Display                 0
Camera                  0
External_Memory         0
Android_version       443
Price                1368
company                 0
Inbuilt_memory         19
fast_charging          89
Screen_resolution       2
Processor              28
Processor_name          0
Price_per_GB_RAM     1368
Price_Rating         1368
Ram_GB                  0
Battery_mAh             0
Screen_Type             2
Total_Storage_GB       19
dtype: int64
In [54]:
df.dropna()
Out[54]:
Unnamed: 0 Rating Spec_score No_of_sim Ram Battery Display Camera External_Memory Android_version ... fast_charging Screen_resolution Processor Processor_name Price_per_GB_RAM Price_Rating Ram_GB Battery_mAh Screen_Type Total_Storage_GB
Name

0 rows × 23 columns

визуализация

In [58]:
import matplotlib.pyplot as plt

линейная диаграмма

In [61]:
plt.figure(figsize=(30, 5)) #графическое окно
df["Rating"].plot(title="Линейная диаграмма")
plt.show
Out[61]:
<function matplotlib.pyplot.show(close=None, block=None)>
No description has been provided for this image

столбчатая диаграмма

In [62]:
plt.figure(figsize= (15, 5))
df["Total_Storage_GB"].value_counts().plot(kind="bar", title="Столбчатая диаграмма")
plt.show
Out[62]:
<function matplotlib.pyplot.show(close=None, block=None)>
No description has been provided for this image

гистограмма

In [78]:
plt.figure(figsize= (10, 5))
df.plot.hist(column=["Rating"], bins = 15)
plt.show
Out[78]:
<function matplotlib.pyplot.show(close=None, block=None)>
<Figure size 1000x500 with 0 Axes>
No description has been provided for this image

ящик с усами

In [82]:
plt.figure(figsize= (10, 65))
df["Battery_mAh"].plot(kind = "box", title="Ящик с усами")
plt.show
Out[82]:
<function matplotlib.pyplot.show(close=None, block=None)>
No description has been provided for this image

диаграммы с областями

In [70]:
from pyparsing import alphas


plt.figure(figsize= (10, 5))
df[["Rating", "Total_Storage_GB"]].plot(
        kind="area", alpha=0.5, title="диаграммы с областями"
    )
plt.show
Out[70]:
<function matplotlib.pyplot.show(close=None, block=None)>
<Figure size 1000x500 with 0 Axes>
No description has been provided for this image

диаграмма рассеивания

In [73]:
df.plot.scatter(x="Rating", y ="Ram_GB")
Out[73]:
<Axes: xlabel='Rating', ylabel='Ram_GB'>
No description has been provided for this image

круговая диаграмма

In [76]:
plt.figure(figsize=(10,5))
rat_counts = df ["Rating"].value_counts()

#данные на 2 группы
under_4 = rat_counts[rat_counts.index<4].sum()
over_4 = rat_counts[rat_counts.index>4].sum()

#создаем данные
labels = ["до 4", "4 и выше"]
sizes = [under_4, over_4] # размеры в процентах 

#строим
plt.pie(sizes, labels=labels, autopct="%1.1f%%")
plt.title("круговая диаграмма")
plt.axis("equal") #чтобы круг
plt.show
Out[76]:
<function matplotlib.pyplot.show(close=None, block=None)>
No description has been provided for this image