import pandas as pd import matplotlib.pyplot as plt # 读取数据包 data = {'公司规模': ['小型', '中型', '大型', '小型', '中型'], '所在城市': ['上海', '北京', '深圳', '广州', '北京'], '月薪': [8000, 12000, 15000, 9000, 13000], '福利': ['五险一金', '带薪年假', '年终奖', '五险一金', '带薪年假']} df = pd.DataFrame(data) # 数据分析 print(df.describe()) # 数据可视化 plt.figure(figsize=(10, 6)) df['公司规模'].value_counts().plot(kind='bar', color='skyblue') plt.title('公司规模分布') plt.xlabel('公司规模') plt.ylabel('数量') plt.show() plt.figure(figsize=(10, 6)) df['所在城市'].value_counts().plot(kind='pie', autopct='%1.1f%%') plt.title('所在城市分布') plt.show() plt.figure(figsize=(10, 6)) plt.hist(df['月薪'], bins=5, color='lightgreen') plt.title('月薪分布') plt.xlabel('月薪') plt.ylabel('数量') plt.show() plt.figure(figsize=(10, 6)) df['福利'].value_counts().plot(kind='bar', color='purple') plt.title('福利分布') plt.xlabel('福利') plt.ylabel('数量') plt.show() [2024-11-12 20:39:59 | AI写代码神器 | 675点数解答]