本文整理匯總了Python中MOSES.getFirstDayOfWeek方法的典型用法代碼示例。如果您正苦於以下問題:Python MOSES.getFirstDayOfWeek方法的具體用法?Python MOSES.getFirstDayOfWeek怎麽用?Python MOSES.getFirstDayOfWeek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MOSES
的用法示例。
在下文中一共展示了MOSES.getFirstDayOfWeek方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getWriterStatsForDate
# 需要導入模塊: import MOSES [as 別名]
# 或者: from MOSES import getFirstDayOfWeek [as 別名]
def getWriterStatsForDate(self, query_date):
lwd = MOSES.getLastWorkingDate(self.user_id, self.password, query_date)
lwd_efficiency = None
lwd_cfm, lwd_gseo, lwd_fatals = None, None, None
previous_dictionary = self.result_dictionary.get(lwd)
if lwd in self.getProcessedDates():
lwd_efficiency = previous_dictionary.get("Efficiency")
lwd_cfm = previous_dictionary.get("CFM")
lwd_gseo = previous_dictionary.get("GSEO")
lwd_fatals = previous_dictionary.get("Fatals")
if lwd_efficiency is None or lwd_cfm is None or lwd_gseo is None or lwd_fatals is None:
self.updateResultsDictionaryForDate(lwd)
previous_dictionary = self.result_dictionary.get(lwd)
lwd_efficiency = previous_dictionary.get("Efficiency")
previous_dictionary = self.result_dictionary.get(lwd)
lwd_cfm = previous_dictionary.get("CFM")
lwd_gseo = previous_dictionary.get("GSEO")
lwd_fatals = previous_dictionary.get("Fatals")
stats_keys = ["Time Frame", "Efficiency", "CFM", "GSEO"]
lwd_stats = [lwd, lwd_efficiency, lwd_cfm, lwd_gseo]
first_date_of_week = MOSES.getFirstDayOfWeek(lwd)
if first_date_of_week == lwd:
cw_stats = ["Week#%d"%lwd.isocalendar()[1]] + lwd_stats[1:]
else:
cw_efficiency = MOSES.getEfficiencyForWeek(self.user_id, self.password, lwd, category_tree=self.category_tree)
cw_cfm, cw_gseo, cw_fatals = MOSES.getCFMGSEOForWeek(self.user_id, self.password, lwd)
cw_stats = ["Week#%d"%lwd.isocalendar()[1], cw_efficiency, cw_cfm, cw_gseo]
cm_efficiency = MOSES.getEfficiencyForMonth(self.user_id, self.password, lwd, category_tree=self.category_tree)
cm_cfm, cm_gseo, cm_fatals = MOSES.getCFMGSEOForMonth(self.user_id, self.password, lwd)
current_month = lwd.strftime("%b") if (len(lwd.strftime("%B"))>6) else lwd.strftime("%B")
cm_stats = [current_month, cm_efficiency, cm_cfm, cm_gseo]
stats = [lwd_stats, cw_stats, cm_stats]
formatted_stats = []
for row in stats:
formatted_row = [row[0]]
for item in row[1:]:
if (type(item) is str) or (item is None):
item = "-"
elif math.isnan(item) :
item = "-"
else:
item = "%6.3f%%"%(item*100)
formatted_row.append(item)
formatted_stats.append(formatted_row)
return pd.DataFrame(formatted_stats, columns=stats_keys)