feat(商务大数据分析): 添加二手车数据分析任务
- 新增二手车数据源读取和分析任务 - 完成车辆价格分布、销量品牌分布、排放标准分析等9项需求 - 添加数据预处理步骤,包括数据清洗、类型转换等 - 使用pandas进行数据处理和分析 - 新增second_cars_info.csv文件的GBK编码配置 - 更新VCS配置,将项目目录映射到Git版本控制系统
This commit is contained in:
parent
655911b748
commit
38d132913a
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/商务大数据分析/20250402/data/中国城市人口数据.csv" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/商务大数据分析/20250416/data/second_cars_info.csv" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
4
.idea/vcs.xml
generated
4
.idea/vcs.xml
generated
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
11282
商务大数据分析/20250416/data/second_cars_info.csv
Normal file
11282
商务大数据分析/20250416/data/second_cars_info.csv
Normal file
File diff suppressed because it is too large
Load Diff
936
商务大数据分析/20250416/task.ipynb
Normal file
936
商务大数据分析/20250416/task.ipynb
Normal file
@ -0,0 +1,936 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"请读取二手车数据源,完成以下需求,在notebook中运行代码,将完整运行结果导出为pdf上传。\n",
|
||||
"\n",
|
||||
"1、车辆价格分布情况\n",
|
||||
"\n",
|
||||
"2、车辆销量品牌分布\n",
|
||||
"\n",
|
||||
"3、排放标准分析\n",
|
||||
"\n",
|
||||
"4、车龄分析\n",
|
||||
"\n",
|
||||
"5、里程分析\n",
|
||||
"\n",
|
||||
"6、折旧价格分析\n",
|
||||
"\n",
|
||||
"7、不同品牌新车平均价格对比\n",
|
||||
"\n",
|
||||
"8、排放标准与行驶里程的关系\n",
|
||||
"\n",
|
||||
"9、车龄与二手车价格的相关性"
|
||||
],
|
||||
"id": "2ce470d74c7f8f38"
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.419400Z",
|
||||
"start_time": "2025-04-18T02:17:28.417330Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": "import pandas as pd",
|
||||
"id": "ca151ea5138a6483",
|
||||
"outputs": [],
|
||||
"execution_count": 81
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.463954Z",
|
||||
"start_time": "2025-04-18T02:17:28.440605Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"car = pd.read_csv('./data/second_cars_info.csv',encoding='gbk')\n",
|
||||
"car.head(5)"
|
||||
],
|
||||
"id": "cafa1492fc572672",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" Brand Name Boarding_time Km Discharge排放标准 \\\n",
|
||||
"0 奥迪 奥迪A6L 2006款 2.4 CVT 舒适型 2006年8月 9.00万公里 国3 \n",
|
||||
"1 奥迪 奥迪A6L 2007款 2.4 CVT 舒适型 2007年1月 8.00万公里 国4 \n",
|
||||
"2 奥迪 奥迪A6L 2004款 2.4L 技术领先型 2005年5月 15.00万公里 国2 \n",
|
||||
"3 奥迪 奥迪A8L 2013款 45 TFSI quattro舒适型 2013年10月 4.80万公里 欧4 \n",
|
||||
"4 奥迪 奥迪A6L 2014款 30 FSI 豪华型 2014年9月 0.81万公里 国4,国5 \n",
|
||||
"\n",
|
||||
" Sec_price New_price \n",
|
||||
"0 6.90 50.89万 \n",
|
||||
"1 8.88 50.89万 \n",
|
||||
"2 3.82 54.24万 \n",
|
||||
"3 44.80 101.06万 \n",
|
||||
"4 33.19 54.99万 "
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Brand</th>\n",
|
||||
" <th>Name</th>\n",
|
||||
" <th>Boarding_time</th>\n",
|
||||
" <th>Km</th>\n",
|
||||
" <th>Discharge排放标准</th>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" <th>New_price</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2006款 2.4 CVT 舒适型</td>\n",
|
||||
" <td>2006年8月</td>\n",
|
||||
" <td>9.00万公里</td>\n",
|
||||
" <td>国3</td>\n",
|
||||
" <td>6.90</td>\n",
|
||||
" <td>50.89万</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2007款 2.4 CVT 舒适型</td>\n",
|
||||
" <td>2007年1月</td>\n",
|
||||
" <td>8.00万公里</td>\n",
|
||||
" <td>国4</td>\n",
|
||||
" <td>8.88</td>\n",
|
||||
" <td>50.89万</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2004款 2.4L 技术领先型</td>\n",
|
||||
" <td>2005年5月</td>\n",
|
||||
" <td>15.00万公里</td>\n",
|
||||
" <td>国2</td>\n",
|
||||
" <td>3.82</td>\n",
|
||||
" <td>54.24万</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A8L 2013款 45 TFSI quattro舒适型</td>\n",
|
||||
" <td>2013年10月</td>\n",
|
||||
" <td>4.80万公里</td>\n",
|
||||
" <td>欧4</td>\n",
|
||||
" <td>44.80</td>\n",
|
||||
" <td>101.06万</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2014款 30 FSI 豪华型</td>\n",
|
||||
" <td>2014年9月</td>\n",
|
||||
" <td>0.81万公里</td>\n",
|
||||
" <td>国4,国5</td>\n",
|
||||
" <td>33.19</td>\n",
|
||||
" <td>54.99万</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
"execution_count": 82,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 82
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.513253Z",
|
||||
"start_time": "2025-04-18T02:17:28.491887Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from decimal import Decimal\n",
|
||||
"car[\"Km\"] = car[\"Km\"].str.extract(\"(\\d+\\.?\\d+)\",expand = True)\n",
|
||||
"car[\"New_price\"] = car[\"New_price\"].str.extract(\"(\\d+\\.?\\d+)\",expand = True)\n",
|
||||
"car[\"New_price\"] = car[\"New_price\"].apply(lambda x : Decimal(x) * 10000)\n",
|
||||
"# car[\"Sec_price\"] = car[\"Sec_price\"].apply(lambda x : Decimal(str(x)) * 10000)\n",
|
||||
"# car[\"Km\"] = car[\"Km\"].apply(lambda x : Decimal(str(x)) * 10000)\n",
|
||||
"car.head(5)"
|
||||
],
|
||||
"id": "1094ed7ec64fd6d3",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" Brand Name Boarding_time Km Discharge排放标准 \\\n",
|
||||
"0 奥迪 奥迪A6L 2006款 2.4 CVT 舒适型 2006年8月 9.00 国3 \n",
|
||||
"1 奥迪 奥迪A6L 2007款 2.4 CVT 舒适型 2007年1月 8.00 国4 \n",
|
||||
"2 奥迪 奥迪A6L 2004款 2.4L 技术领先型 2005年5月 15.00 国2 \n",
|
||||
"3 奥迪 奥迪A8L 2013款 45 TFSI quattro舒适型 2013年10月 4.80 欧4 \n",
|
||||
"4 奥迪 奥迪A6L 2014款 30 FSI 豪华型 2014年9月 0.81 国4,国5 \n",
|
||||
"\n",
|
||||
" Sec_price New_price \n",
|
||||
"0 6.90 508900.00 \n",
|
||||
"1 8.88 508900.00 \n",
|
||||
"2 3.82 542400.00 \n",
|
||||
"3 44.80 1010600.00 \n",
|
||||
"4 33.19 549900.00 "
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Brand</th>\n",
|
||||
" <th>Name</th>\n",
|
||||
" <th>Boarding_time</th>\n",
|
||||
" <th>Km</th>\n",
|
||||
" <th>Discharge排放标准</th>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" <th>New_price</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2006款 2.4 CVT 舒适型</td>\n",
|
||||
" <td>2006年8月</td>\n",
|
||||
" <td>9.00</td>\n",
|
||||
" <td>国3</td>\n",
|
||||
" <td>6.90</td>\n",
|
||||
" <td>508900.00</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2007款 2.4 CVT 舒适型</td>\n",
|
||||
" <td>2007年1月</td>\n",
|
||||
" <td>8.00</td>\n",
|
||||
" <td>国4</td>\n",
|
||||
" <td>8.88</td>\n",
|
||||
" <td>508900.00</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2004款 2.4L 技术领先型</td>\n",
|
||||
" <td>2005年5月</td>\n",
|
||||
" <td>15.00</td>\n",
|
||||
" <td>国2</td>\n",
|
||||
" <td>3.82</td>\n",
|
||||
" <td>542400.00</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A8L 2013款 45 TFSI quattro舒适型</td>\n",
|
||||
" <td>2013年10月</td>\n",
|
||||
" <td>4.80</td>\n",
|
||||
" <td>欧4</td>\n",
|
||||
" <td>44.80</td>\n",
|
||||
" <td>1010600.00</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2014款 30 FSI 豪华型</td>\n",
|
||||
" <td>2014年9月</td>\n",
|
||||
" <td>0.81</td>\n",
|
||||
" <td>国4,国5</td>\n",
|
||||
" <td>33.19</td>\n",
|
||||
" <td>549900.00</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
"execution_count": 83,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 83
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.568207Z",
|
||||
"start_time": "2025-04-18T02:17:28.555681Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"car['Boarding_time'] = pd.to_datetime(car['Boarding_time'].str.replace('年', '-').str.replace('月', ''), errors='coerce', format='%Y-%m')\n",
|
||||
"car.head(3)"
|
||||
],
|
||||
"id": "2df80c752148dcd1",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" Brand Name Boarding_time Km Discharge排放标准 \\\n",
|
||||
"0 奥迪 奥迪A6L 2006款 2.4 CVT 舒适型 2006-08-01 9.00 国3 \n",
|
||||
"1 奥迪 奥迪A6L 2007款 2.4 CVT 舒适型 2007-01-01 8.00 国4 \n",
|
||||
"2 奥迪 奥迪A6L 2004款 2.4L 技术领先型 2005-05-01 15.00 国2 \n",
|
||||
"\n",
|
||||
" Sec_price New_price \n",
|
||||
"0 6.90 508900.00 \n",
|
||||
"1 8.88 508900.00 \n",
|
||||
"2 3.82 542400.00 "
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Brand</th>\n",
|
||||
" <th>Name</th>\n",
|
||||
" <th>Boarding_time</th>\n",
|
||||
" <th>Km</th>\n",
|
||||
" <th>Discharge排放标准</th>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" <th>New_price</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2006款 2.4 CVT 舒适型</td>\n",
|
||||
" <td>2006-08-01</td>\n",
|
||||
" <td>9.00</td>\n",
|
||||
" <td>国3</td>\n",
|
||||
" <td>6.90</td>\n",
|
||||
" <td>508900.00</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2007款 2.4 CVT 舒适型</td>\n",
|
||||
" <td>2007-01-01</td>\n",
|
||||
" <td>8.00</td>\n",
|
||||
" <td>国4</td>\n",
|
||||
" <td>8.88</td>\n",
|
||||
" <td>508900.00</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>奥迪</td>\n",
|
||||
" <td>奥迪A6L 2004款 2.4L 技术领先型</td>\n",
|
||||
" <td>2005-05-01</td>\n",
|
||||
" <td>15.00</td>\n",
|
||||
" <td>国2</td>\n",
|
||||
" <td>3.82</td>\n",
|
||||
" <td>542400.00</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
"execution_count": 84,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 84
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.626329Z",
|
||||
"start_time": "2025-04-18T02:17:28.622360Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"today = pd.Timestamp('today')\n",
|
||||
"car['Year'] = today.year - car['Boarding_time'].dt.year\n",
|
||||
"car['Month'] = today.month - car['Boarding_time'].dt.month\n",
|
||||
"car['Year'] = car['Year'] + car['Month'] / 12"
|
||||
],
|
||||
"id": "adb1e9029cf50440",
|
||||
"outputs": [],
|
||||
"execution_count": 85
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.693439Z",
|
||||
"start_time": "2025-04-18T02:17:28.689606Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 1、车辆价格分布情况\n",
|
||||
"car['Sec_price'].describe()"
|
||||
],
|
||||
"id": "192ca8d230bba52c",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"count 11281.000000\n",
|
||||
"mean 26.897567\n",
|
||||
"std 55.451814\n",
|
||||
"min 0.650000\n",
|
||||
"25% 5.200000\n",
|
||||
"50% 10.490000\n",
|
||||
"75% 24.800000\n",
|
||||
"max 808.000000\n",
|
||||
"Name: Sec_price, dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 86,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 86
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.759802Z",
|
||||
"start_time": "2025-04-18T02:17:28.755785Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 2、车辆销量品牌分布\n",
|
||||
"car['Brand'].value_counts()"
|
||||
],
|
||||
"id": "84cd0ac0f5397e98",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"别克 1350\n",
|
||||
"大众 991\n",
|
||||
"奔驰 895\n",
|
||||
"宝马 773\n",
|
||||
"奥迪 758\n",
|
||||
" ... \n",
|
||||
"东风风光 1\n",
|
||||
"昌河 1\n",
|
||||
"北汽制造 1\n",
|
||||
"北京 1\n",
|
||||
"中欧房车 1\n",
|
||||
"Name: Brand, Length: 104, dtype: int64"
|
||||
]
|
||||
},
|
||||
"execution_count": 87,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 87
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.829496Z",
|
||||
"start_time": "2025-04-18T02:17:28.826138Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 3、排放标准分析\n",
|
||||
"car['Discharge排放标准'].value_counts()"
|
||||
],
|
||||
"id": "abfa9e35e2c0e57b",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"国4 4300\n",
|
||||
"欧4 1898\n",
|
||||
"欧5 1201\n",
|
||||
"国4,国5 848\n",
|
||||
"国3 798\n",
|
||||
"国5 683\n",
|
||||
"欧3 292\n",
|
||||
"-- 276\n",
|
||||
"国2 241\n",
|
||||
"国4,京5 223\n",
|
||||
"国3,OBD 119\n",
|
||||
"OBD 90\n",
|
||||
"国4,OBD 63\n",
|
||||
"欧4,OBD 62\n",
|
||||
"OBD,国5 38\n",
|
||||
"欧6 36\n",
|
||||
"国4,OBD,国5 31\n",
|
||||
"国5,京5 22\n",
|
||||
"欧5,OBD 9\n",
|
||||
"欧4,欧5 9\n",
|
||||
"欧5,国4 7\n",
|
||||
"欧4,国3 7\n",
|
||||
"国4,OBD,京5 6\n",
|
||||
"欧4,国4 6\n",
|
||||
"欧4,国4,OBD 5\n",
|
||||
"欧3,欧4 2\n",
|
||||
"欧5,国5 2\n",
|
||||
"国4,国5,京5 1\n",
|
||||
"欧1 1\n",
|
||||
"欧2 1\n",
|
||||
"京5 1\n",
|
||||
"国3,国4 1\n",
|
||||
"欧4,-- 1\n",
|
||||
"欧5,国4,国5 1\n",
|
||||
"Name: Discharge排放标准, dtype: int64"
|
||||
]
|
||||
},
|
||||
"execution_count": 88,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 88
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.890889Z",
|
||||
"start_time": "2025-04-18T02:17:28.886821Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 4、车龄分析\n",
|
||||
"car['Year'].describe()"
|
||||
],
|
||||
"id": "93126f910d7182c6",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"count 11188.000000\n",
|
||||
"mean 13.123592\n",
|
||||
"std 2.991405\n",
|
||||
"min 7.500000\n",
|
||||
"25% 10.750000\n",
|
||||
"50% 13.166667\n",
|
||||
"75% 15.083333\n",
|
||||
"max 27.333333\n",
|
||||
"Name: Year, dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 89,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 89
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:28.960584Z",
|
||||
"start_time": "2025-04-18T02:17:28.955583Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 5、里程分析\n",
|
||||
"car['Km'].describe()"
|
||||
],
|
||||
"id": "9a5d106b4e15e8a2",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"count 11184\n",
|
||||
"unique 968\n",
|
||||
"top 6.00\n",
|
||||
"freq 485\n",
|
||||
"Name: Km, dtype: object"
|
||||
]
|
||||
},
|
||||
"execution_count": 90,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 90
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:17:29.031125Z",
|
||||
"start_time": "2025-04-18T02:17:29.024995Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 6、折旧价格分析\n",
|
||||
"# car = car.dropna(subset=['Km'])\n",
|
||||
"car[['Km', 'Sec_price']].corr()"
|
||||
],
|
||||
"id": "52035886c7842d2f",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" Sec_price\n",
|
||||
"Sec_price 1.0"
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" <td>1.0</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
"execution_count": 91,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 91
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:23:06.001261Z",
|
||||
"start_time": "2025-04-18T02:23:05.987085Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 7、不同品牌新车平均价格对比\n",
|
||||
"car[['Brand', 'New_price']].groupby('Brand').mean()"
|
||||
],
|
||||
"id": "568eaf05460ebb68",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" New_price\n",
|
||||
"Brand \n",
|
||||
"DS 2.644188e+05\n",
|
||||
"GMC 1.423178e+06\n",
|
||||
"Jeep 4.342455e+05\n",
|
||||
"MINI 3.076827e+05\n",
|
||||
"WEY 1.930000e+05\n",
|
||||
"... ...\n",
|
||||
"雪佛兰 1.564546e+05\n",
|
||||
"雪铁龙 1.655019e+05\n",
|
||||
"雷克萨斯 7.538173e+05\n",
|
||||
"雷诺 2.770526e+05\n",
|
||||
"马自达 2.170586e+05\n",
|
||||
"\n",
|
||||
"[104 rows x 1 columns]"
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>New_price</th>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Brand</th>\n",
|
||||
" <th></th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>DS</th>\n",
|
||||
" <td>2.644188e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>GMC</th>\n",
|
||||
" <td>1.423178e+06</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Jeep</th>\n",
|
||||
" <td>4.342455e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>MINI</th>\n",
|
||||
" <td>3.076827e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>WEY</th>\n",
|
||||
" <td>1.930000e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>雪佛兰</th>\n",
|
||||
" <td>1.564546e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>雪铁龙</th>\n",
|
||||
" <td>1.655019e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>雷克萨斯</th>\n",
|
||||
" <td>7.538173e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>雷诺</th>\n",
|
||||
" <td>2.770526e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>马自达</th>\n",
|
||||
" <td>2.170586e+05</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>104 rows × 1 columns</p>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
"execution_count": 96,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 96
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:25:53.211176Z",
|
||||
"start_time": "2025-04-18T02:25:53.179478Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 8、排放标准与行驶里程的关系\n",
|
||||
"car['Km'] = pd.to_numeric(car['Km'], errors='coerce')\n",
|
||||
"car.groupby('Discharge排放标准')['Km'].mean()"
|
||||
],
|
||||
"id": "4af30a35353b2754",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Discharge排放标准\n",
|
||||
"-- 6.302677\n",
|
||||
"OBD 8.320222\n",
|
||||
"OBD,国5 3.307105\n",
|
||||
"京5 2.000000\n",
|
||||
"国2 11.470539\n",
|
||||
"国3 8.524411\n",
|
||||
"国3,OBD 7.691681\n",
|
||||
"国3,国4 5.000000\n",
|
||||
"国4 7.075801\n",
|
||||
"国4,OBD 5.169841\n",
|
||||
"国4,OBD,京5 5.533333\n",
|
||||
"国4,OBD,国5 4.262258\n",
|
||||
"国4,京5 4.808879\n",
|
||||
"国4,国5 4.026185\n",
|
||||
"国4,国5,京5 3.400000\n",
|
||||
"国5 2.302224\n",
|
||||
"国5,京5 3.365455\n",
|
||||
"欧1 8.000000\n",
|
||||
"欧2 12.000000\n",
|
||||
"欧3 9.064828\n",
|
||||
"欧3,欧4 8.000000\n",
|
||||
"欧4 6.729597\n",
|
||||
"欧4,-- 7.500000\n",
|
||||
"欧4,OBD 5.134426\n",
|
||||
"欧4,国3 8.914286\n",
|
||||
"欧4,国4 6.133333\n",
|
||||
"欧4,国4,OBD 7.460000\n",
|
||||
"欧4,欧5 4.120000\n",
|
||||
"欧5 3.364559\n",
|
||||
"欧5,OBD 4.911111\n",
|
||||
"欧5,国4 4.382857\n",
|
||||
"欧5,国4,国5 7.000000\n",
|
||||
"欧5,国5 0.650000\n",
|
||||
"欧6 1.073714\n",
|
||||
"Name: Km, dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 99,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 99
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-18T02:26:08.841815Z",
|
||||
"start_time": "2025-04-18T02:26:08.835149Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 9、车龄与二手车价格的相关性\n",
|
||||
"car[['Year', 'Sec_price']].corr()"
|
||||
],
|
||||
"id": "ab1c177ba107b9bc",
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" Year Sec_price\n",
|
||||
"Year 1.00000 -0.30768\n",
|
||||
"Sec_price -0.30768 1.00000"
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Year</th>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>Year</th>\n",
|
||||
" <td>1.00000</td>\n",
|
||||
" <td>-0.30768</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Sec_price</th>\n",
|
||||
" <td>-0.30768</td>\n",
|
||||
" <td>1.00000</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
"execution_count": 100,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 100
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user