-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworktime2.py
46 lines (37 loc) · 1.24 KB
/
worktime2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 计算从运营平台时长统计导出的数据,进行格式转换
import numpy as np
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import datetime
df = pd.read_excel("~/Desktop/西海岸人员数据.xlsx")
rows=len(df.index)
cols=len(df.columns)-2
for row in range(rows):
for col in range(3):
str1 = str(df.iloc[row, col + 4])
#print(str1)
hs = "0"
ms = "0"
#print(str1)
if str1.find("h")>-1:
hs=str1[0:str1.find("h")]
ms=str1[str1.find("h")+1:len(str1)]
if ms=="": ms="0"
else:
ms=int(str1) #没有"h" 只有分钟数
worktime=int(hs)*60+int(ms)
#print(hs, ms)
df.iloc[row, col+4]=worktime
df.to_excel("~/Desktop/xihaian_output.xlsx")
#title="Staying Time"
#sns.set_style("whitegrid")
# plt.rcParams['font.sans-serif'] = ['SimHei'] # 黑体
# plt.rcParams['axes.unicode_minus'] = False # 解决无法显示符号的问题
# sns.set(font='SimHei', font_scale=0.8) # 解决Seaborn中文显示问题
#sns.set(rc={'figure.figsize':(11.7,6.27)})
#floorTime=df["2022-09-20"]
#floorList=df.index.values
#fig=sns.barplot(x=floorList, y=floorTime, color="grey")
#fig.set_title(title)
#plt.show()