# BigData **Repository Path**: twispark/big-data ## Basic Information - **Project Name**: BigData - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-13 - **Last Updated**: 2024-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 2024年各厂商各车型的探索可视化分析 ``` import pandas as pd import plotly.express as px import plotly.graph_objects as go ``` 数据来源:汽车分厂商每月销售表_241115_1731635513.xlsx ``` df = pd.read_excel("/home/mw/input/CAR5432/汽车分厂商每月销售表_241115_1731635513.xlsx") df.head() ``` | 年份 | 月份 | 排名 | 厂商 | 销量 | 占销量份额 | |------|----|----|------|--------|-------| | 2024 | 1 | 1 | 比亚迪 | 190761 | 9.38% | | 2024 | 1 | 2 | 长安汽车 | 130408 | 6.41% | | 2024 | 1 | 3 | 吉利汽车 | 119235 | 5.86% | | 2024 | 1 | 4 | 上汽大众 | 111467 | 5.48% | | 2024 | 1 | 5 | 一汽大众 | 98000 | 4.82% | ``` df.info() ``` RangeIndex: 12577 entries, 0 to 12576 Data columns (total 6 columns): 年份 12577 non-null int64 月份 12577 non-null int64 排名 12577 non-null int64 厂商 12572 non-null object 销量 12577 non-null int64 占销量份额 12577 non-null object dtypes: int64(4), object(2) memory usage: 589.6+ KB ### ## 时间序列分析 我们可以分析不同年份和月份的销售趋势,了解销售高峰和低谷。 ``` df['日期'] = pd.to_datetime(df['年份'].astype(str) + '-' + df['月份'].astype(str), format='%Y-%m') monthly_sales = df.groupby('日期')['销量'].sum().reset_index() monthly_sales.head() ``` ||日期|销量| |--|--|--| |0|2015-01-01|2143808| |1|2015-02-01|1475306| |2|2015-03-01|1974836| |3|2015-04-01|1789384| |4|2015-05-01|1717550| ``` # 创建 Plotly 图表 fig = go.Figure() # 添加折线图 fig.add_trace(go.Scatter(x=monthly_sales['日期'], y=monthly_sales['销量'], mode='lines+markers', name='销量', line=dict(color='blue', width=2), marker=dict(symbol='circle', size=6, color='blue'))) # 设置标题和标签 fig.update_layout( title='不同年份和月份的汽车销售趋势', xaxis_title='日期', yaxis_title='销量', xaxis_tickangle=45, title_x=0.5, template='plotly_white', autosize=True ) fig.add_annotation( text="制图:布鲁的Python之旅", xref="paper", yref="paper", x=0.5, y=0.5, showarrow=False, font=dict( family="Arial", size=20, color="lightgrey" ), opacity=0.5, xanchor='center' ) # 显示图表 fig.show() ```