In [1]:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_style("whitegrid")
from scipy.stats import f_oneway
import warnings
warnings.filterwarnings('ignore')
df = pd.read_csv("smartphones.csv")
df.head()
df.shape
df.info()
df.describe()
df.describe(include='O')
df.isnull().sum()
df.duplicated().sum()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 980 entries, 0 to 979 Data columns (total 22 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 brand_name 980 non-null object 1 model 980 non-null object 2 price 980 non-null int64 3 avg_rating 879 non-null float64 4 5G_or_not 980 non-null int64 5 processor_brand 960 non-null object 6 num_cores 974 non-null float64 7 processor_speed 938 non-null float64 8 battery_capacity 969 non-null float64 9 fast_charging_available 980 non-null int64 10 fast_charging 769 non-null float64 11 ram_capacity 980 non-null int64 12 internal_memory 980 non-null int64 13 screen_size 980 non-null float64 14 refresh_rate 980 non-null int64 15 num_rear_cameras 980 non-null int64 16 os 966 non-null object 17 primary_camera_rear 980 non-null float64 18 primary_camera_front 975 non-null float64 19 extended_memory_available 980 non-null int64 20 resolution_height 980 non-null int64 21 resolution_width 980 non-null int64 dtypes: float64(8), int64(10), object(4) memory usage: 168.6+ KB
Out[1]:
0
In [7]:
import pandas as pd
# 读取 CSV 文件
df = pd.read_csv('smartphones.csv')
# 修改列名
df = df.rename(columns={
'brand_name': 'Brand',
'model': 'Model',
'price': 'Final Price',
'ram_capacity': 'RAM',
'internal_memory': 'Storage',
'avg_rating': 'Color',
'5G_or_not': 'Free',
'processor_brand': 'Smartphone'
})
# 保存修改后的 CSV 文件
df.to_csv('smartphonesnew_file.csv', index=False)
In [3]:
df = df.rename(columns={'model': 'Model'})
df = df.rename(columns={'brand_name': 'Brand'})
df = df.rename(columns={'model': 'Model'})
df = df.rename(columns={'model': 'Model'})
df = df.rename(columns={'model': 'Model'})
Out[3]:
| price | avg_rating | 5G_or_not | num_cores | processor_speed | battery_capacity | fast_charging_available | fast_charging | ram_capacity | internal_memory | screen_size | refresh_rate | num_rear_cameras | primary_camera_rear | primary_camera_front | extended_memory_available | resolution_height | resolution_width | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 980.000000 | 879.000000 | 980.000000 | 974.000000 | 938.000000 | 969.000000 | 980.000000 | 769.000000 | 980.000000 | 980.000000 | 980.000000 | 980.000000 | 980.000000 | 980.000000 | 975.000000 | 980.000000 | 980.000000 | 980.000000 |
| mean | 32520.504082 | 7.825825 | 0.560204 | 7.772074 | 2.427217 | 4817.748194 | 0.854082 | 46.126138 | 6.560204 | 141.036735 | 6.536765 | 92.256122 | 2.814286 | 50.319286 | 16.589744 | 0.630612 | 2214.663265 | 1075.852041 |
| std | 39531.812669 | 0.740285 | 0.496616 | 0.836845 | 0.464090 | 1009.540054 | 0.353205 | 34.277870 | 2.744378 | 107.134516 | 0.349162 | 28.988052 | 0.776441 | 33.000968 | 10.876944 | 0.482885 | 516.484254 | 290.164931 |
| min | 3499.000000 | 6.000000 | 0.000000 | 4.000000 | 1.200000 | 1821.000000 | 0.000000 | 10.000000 | 1.000000 | 8.000000 | 3.540000 | 60.000000 | 1.000000 | 2.000000 | 0.000000 | 0.000000 | 480.000000 | 480.000000 |
| 25% | 12999.000000 | 7.400000 | 0.000000 | 8.000000 | 2.050000 | 4500.000000 | 1.000000 | 18.000000 | 4.000000 | 64.000000 | 6.500000 | 60.000000 | 2.000000 | 24.000000 | 8.000000 | 0.000000 | 1612.000000 | 1080.000000 |
| 50% | 19994.500000 | 8.000000 | 1.000000 | 8.000000 | 2.300000 | 5000.000000 | 1.000000 | 33.000000 | 6.000000 | 128.000000 | 6.580000 | 90.000000 | 3.000000 | 50.000000 | 16.000000 | 1.000000 | 2400.000000 | 1080.000000 |
| 75% | 35491.500000 | 8.400000 | 1.000000 | 8.000000 | 2.840000 | 5000.000000 | 1.000000 | 66.000000 | 8.000000 | 128.000000 | 6.670000 | 120.000000 | 3.000000 | 64.000000 | 16.000000 | 1.000000 | 2408.000000 | 1080.000000 |
| max | 650000.000000 | 8.900000 | 1.000000 | 8.000000 | 3.220000 | 22000.000000 | 1.000000 | 240.000000 | 18.000000 | 1024.000000 | 8.030000 | 240.000000 | 4.000000 | 200.000000 | 60.000000 | 1.000000 | 3840.000000 | 2460.000000 |
In [ ]: