From 88b1e939ffa9f4e87ef6a7f49c8cebd7ad5f5503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 14 Apr 2025 17:57:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/shop/sell/business.py | 52 +++++++++++++++++++------------------- dags/shop/sell/price.py | 52 +++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/dags/shop/sell/business.py b/dags/shop/sell/business.py index 3245182..9004561 100644 --- a/dags/shop/sell/business.py +++ b/dags/shop/sell/business.py @@ -84,32 +84,32 @@ def calc(city, year_month): log.info(f"{city} {year_month} 商圈均价计算完毕!") -# yearmonth = sys.argv[1] if len(sys.argv) > 1 else '' -# -# if yearmonth == '': -# date = dateutils.add_months(datetime.today(), months=-1) -# yearmonth = int(dateutils.format_date(date, '%Y%m')) -# try: -# for city in areautils.get_all_cities(): -# calc(city, yearmonth) -# except Exception as e: -# log.error(e) +yearmonth = sys.argv[1] if len(sys.argv) > 1 else '' + +if yearmonth == '': + date = dateutils.add_months(datetime.today(), months=-1) + yearmonth = int(dateutils.format_date(date, '%Y%m')) +try: + for city in areautils.get_all_cities(): + calc(city, yearmonth) +except Exception as e: + log.error(e) # # 初始化从2024年9月 # 创建从2024年9月到2024年12月的日期范围 -date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M') - -# 创建一个包含这些日期的DataFrame -df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)}) - -# 将日期设置为索引 -df.set_index('date', inplace=True) - -# 遍历DataFrame -for city in areautils.get_all_cities(): - for date, row in df.iterrows(): - try: - date_format = int(dateutils.format_date(date, '%Y%m')) - calc(city, date_format) - except Exception as e: - log.error(e) +# date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M') +# +# # 创建一个包含这些日期的DataFrame +# df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)}) +# +# # 将日期设置为索引 +# df.set_index('date', inplace=True) +# +# # 遍历DataFrame +# for city in areautils.get_all_cities(): +# for date, row in df.iterrows(): +# try: +# date_format = int(dateutils.format_date(date, '%Y%m')) +# calc(city, date_format) +# except Exception as e: +# log.error(e) diff --git a/dags/shop/sell/price.py b/dags/shop/sell/price.py index d6690db..02030bb 100644 --- a/dags/shop/sell/price.py +++ b/dags/shop/sell/price.py @@ -81,32 +81,32 @@ def calc(city, year_month): log.info(f"{city} {year_month} 均价计算完毕!") -# yearmonth = sys.argv[1] if len(sys.argv) > 1 else '' -# -# if yearmonth == '': -# date = dateutils.add_months(datetime.today(), months=-1) -# yearmonth = int(dateutils.format_date(date, '%Y%m')) -# try: -# for city in areautils.get_all_cities(): -# calc(city, yearmonth) -# except Exception as e: -# log.error(e) +yearmonth = sys.argv[1] if len(sys.argv) > 1 else '' + +if yearmonth == '': + date = dateutils.add_months(datetime.today(), months=-1) + yearmonth = int(dateutils.format_date(date, '%Y%m')) +try: + for city in areautils.get_all_cities(): + calc(city, yearmonth) +except Exception as e: + log.error(e) # # 初始化从2024年9月 # 创建从2024年9月到2024年12月的日期范围 -date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M') - -# 创建一个包含这些日期的DataFrame -df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)}) - -# 将日期设置为索引 -df.set_index('date', inplace=True) - -# 遍历DataFrame -for city in areautils.get_all_cities(): - for date, row in df.iterrows(): - try: - date_format = int(dateutils.format_date(date, '%Y%m')) - calc(city, date_format) - except Exception as e: - log.error(e) +# date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M') +# +# # 创建一个包含这些日期的DataFrame +# df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)}) +# +# # 将日期设置为索引 +# df.set_index('date', inplace=True) +# +# # 遍历DataFrame +# for city in areautils.get_all_cities(): +# for date, row in df.iterrows(): +# try: +# date_format = int(dateutils.format_date(date, '%Y%m')) +# calc(city, date_format) +# except Exception as e: +# log.error(e)