You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 lines
2.5 KiB

import datetime
import numpy as np
from pandas import DataFrame;
import pandas as pd
from pandas.tseries.offsets import Hour
from common.Def import *
#读取Csv
def ReadCsv(path, name, date):
file = f"{path}/{date}/{name}_{date}.csv"
if os.path.exists(file):
return pd.read_csv(file)
return None;
#读取csvlog数据
def GetCsvData(logtype:LogType, eventtypename, date):
path = CsvPath[logtype.name] if logtype.name in CsvPath.keys() else None
if path == None:
return None
return ReadCsv(path, eventtypename, date)
#读取csvlog数据 带时间偏移
def GetCsvDataShift(logtype:LogType, eventtypename, date, shift = 5):
curdatetime = DateToTime(date)
startime = curdatetime + datetime.timedelta(hours = 5)
endtime = startime + datetime.timedelta(hours = 24)
data1 = GetCsvData(logtype, eventtypename, TimeToDate(startime))
data1 = data1[data1["timeStamp"] >= int(startime.timestamp())]
data2 = GetCsvData(logtype, eventtypename, TimeToDate(endtime))
data2 = data2[data2["timeStamp"] < int(endtime.timestamp())]
return pd.concat([data1, data2])
def DateToTime(date, day = 0):
time = datetime.datetime.strptime(date, '%Y-%m-%d')
if day != 0:
delta = datetime.timedelta(days=day)
time = time + delta
return time
def TimeToDate(time:datetime):
return time.strftime("%Y-%m-%d")
def GetDateNext(time:datetime, day = 0):
delta = datetime.timedelta(days=day)
time = time + delta
return TimeToDate(time)
def GetDateStrNext(date, day):
time = DateToTime(date, day)
return TimeToDate(time)
# def ReadCsv(path, name):
# file = path + "/" + name + ".csv"
# data = pd.read_csv(file)
# return data;
# def AnalyzeOnline():
# player_snapshot = ReadCsv(TA_PATH, "8月1号玩家快照")
# mainline_mission = ReadCsv(TA_PATH, "8月1号战斗记录")
# online_time = ReadCsv(TA_PATH, "核心用户在线时长")
# #排序去重,保留最大通过数
# player_snapshot = player_snapshot.sort_values(by=['Uid', 'mainline'])
# snapshot = player_snapshot.drop_duplicates(subset=["Uid"], keep='last',inplace=False)
# #统计各个副本驻留
# data = pd.merge(snapshot, online_time, on = 'Uid', how="left")
# group_data = data.groupby(by=['mainline'])['time'].agg([
# ("count", np.size),
# ("total", np.sum),
# ("avg", np.mean)
# ]).reset_index()
# group_data.to_csv("./out/1.csv")
# mainline_mission = player_snapshot.sort_values(by=['Uid', 'mainline'])