优化
This commit is contained in:
+26
-26
@@ -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)
|
||||
|
||||
+26
-26
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user