本文整理汇总了Python中Main.getProduct方法的典型用法代码示例。如果您正苦于以下问题:Python Main.getProduct方法的具体用法?Python Main.getProduct怎么用?Python Main.getProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Main
的用法示例。
在下文中一共展示了Main.getProduct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_product_trends
# 需要导入模块: import Main [as 别名]
# 或者: from Main import getProduct [as 别名]
def find_product_trends(database,product_codes):
print("Getting Product Trends...")
Main.fill_values(database)
for hs,product in product_codes.items():
# Find all the Long, Medium, and Short term Trends in products
# print (one_year_val)
five_year_val = Main.getProduct(product, last_year-5)
first_year_val= Main.getProduct(product, first_year)
last_year_val = Main.getProduct(product, last_year)
one_year_val = Main.getProduct(product, last_year-1)
three_year_val= Main.getProduct(product, last_year-3)
# Attempts to lower the calculation requirements by not calculating for products
# that have no values in the data set given
total = first_year_val + last_year_val + one_year_val + five_year_val + three_year_val
if (total == 0):
continue
if (one_year_val != 0):
one_year_trend = (last_year_val - one_year_val )/ one_year_val
one_year_label = "%s-%s" % (product,"one_year_trend")
SQL_Handler.insert("product_trends",one_year_label,one_year_trend,Main.database)
if (three_year_val != 0):
three_year_trend = (last_year_val - three_year_val )/ three_year_val
three_year_trend_label = "%s-%s" % (product,"three_year_trend")
SQL_Handler.insert("product_trends",three_year_trend_label,three_year_trend,Main.database)
if (five_year_val != 0):
five_year_trend = (last_year_val - five_year_val )/ five_year_val
five_year_trend_label = "%s-%s" % (product,"five_year_trend")
SQL_Handler.insert("product_trends",five_year_trend_label,five_year_trend,Main.database)
if (first_year_val != 0):
long_trend = (last_year_val - first_year_val )/ first_year_val
long_trend_label = "%s-%s" % (product,"long_trend")
SQL_Handler.insert("product_trends",long_trend_label,long_trend,Main.database)