def fmtjpi_table # 获取列表中state车辆状态列为1的数据即出停车场 fmdfs = pi_tablelocpi_tablestate == 1 # 转换数据为列表 fmdfs = fmdfsvalues # 定义变量表示每周的繁忙统计 WEEK1 = 0 WEEK2 = 0 WEEK3 = 0 WEEK4 = 0
import matplotlib.pyplot as plt
def fmtj(pi_table): # 获取列表中state(车辆状态)列为1的数据,即出停车场 fmdfs = pi_table.loc[pi_table['state'] == 1] # 转换数据为列表 fmdfs = fmdfs.values
# 定义变量表示每周的繁忙统计
WEEK1 = 0
WEEK2 = 0
WEEK3 = 0
WEEK4 = 0
WEEK5 = 0
WEEK6 = 0
WEEK7 = 0
# 循环数据列表
for fmdf in fmdfs:
# 获取数据对应的星期几
week_number = get_week_number(fmdf[1])
# 根据星期几进行统计
if week_number == 0:
WEEK1 += 1
pass
elif week_number == 1:
WEEK2 += 1
pass
elif week_number == 2:
WEEK3 += 1
pass
elif week_number == 3:
WEEK4 += 1
pass
elif week_number == 4:
WEEK5 += 1
pass
elif week_number == 5:
WEEK6 += 1
pass
elif week_number == 6:
WEEK7 += 1
pass
# 显示饼图
labels = ['WEEK1', 'WEEK2', 'WEEK3', 'WEEK4', 'WEEK5', 'WEEK6', 'WEEK7']
sizes = [WEEK1, WEEK2, WEEK3, WEEK4, WEEK5, WEEK6, WEEK7]
plt.pie(sizes, labels=labels, autopct='%1.1f%%')
plt.axis('equal')
plt.show()
原文地址: https://www.cveoy.top/t/topic/i5uz 著作权归作者所有。请勿转载和采集!