### 1. 环境准备
```python
# 安装必要库
!pip install pandas matplotlib jieba wordcloud pyecharts networkx pillow tencentcloud-sdk-python
```
---
### 2. 数据读取与预处理
```python
import pandas as pd
# 读取数据(假设为Excel文件)
df = pd.read_excel("学生信息表.xlsx", engine='openpyxl')
# 查看数据结构
print(df.head())
print(df.info())
# 示例预处理(根据实际数据调整)
df['省份'] = df['省份'].str.replace('省', '').replace('市', '') # 标准化省份名称
```
---
### 3. 性别分布饼图
```python
import matplotlib.pyplot as plt
gender_counts = df['性别'].value_counts()
plt.pie(gender_counts, labels=gender_counts.index, autopct='%1.1f%%')
plt.title("Gender Distribution")
plt.show()
```
---
### 4. 省份分布地图(使用pyecharts)
```python
from pyecharts import options as opts
from pyecharts.charts import Map
province_counts = df['省份'].value_counts().to_dict()
c = (
Map()
.add("学生数量", list(province_counts.items()), "china")
.set_global_opts(title_opts=opts.TitleOpts(title="Province Distribution"))
c.render("province_map.html") # 生成交互式HTML文件
```
---
### 5. 城市分布柱状图
```python
city_counts = df['城市'].value_counts().head(10) # 取前10个城市
plt.bar(city_counts.index, city_counts.values)
plt.xticks(rotation=45)
plt.title("Top 10 Cities")
plt.show()
```
---
### 6. 签名词云
```python
from wordcloud import WordCloud
import jieba
text = ' '.join(df['签名'].dropna())
words = ' '.join(jieba.cut(text