helenlee01

读取excel数据,使用xlrd制作散点图。

import matplotlib.pyplot as plt 
import xlrd

data = xlrd.open_workbook(\'测试3.xlsx\') # 读取工作表
table = data.sheet_by_name(\'Sheet1\') # 读取当前sheet表对象
rows = table.nrows # 获取行数
nianlist = []
citylist = []
salarylist = []
print(\'一共有{}行数据\'.format(rows))
for i in range(1,rows):
    salary = table.row_values(i)[3]
    nian = table.row_values(i)[6]
    city = table.row_values(i)[8]
    nianlist.append(nian)
    citylist.append(city)
    salarylist.append(salary)
plt.scatter(citylist, salarylist, s=10) 
plt.show()

 

分类:

技术点:

相关文章:

  • 2021-08-02
  • 2022-01-21
  • 2021-11-11
  • 2021-08-22
  • 2021-04-16
  • 2021-11-05
  • 2021-12-28
  • 2021-12-02
猜你喜欢
  • 2020-07-11
  • 2021-05-25
  • 2021-10-19
  • 2021-05-10
  • 2021-04-02
  • 2021-12-16
  • 2021-12-22
相关资源
相似解决方案