优化
This commit is contained in:
+26
-26
@@ -84,32 +84,32 @@ def calc(city, year_month):
|
|||||||
log.info(f"{city} {year_month} 商圈均价计算完毕!")
|
log.info(f"{city} {year_month} 商圈均价计算完毕!")
|
||||||
|
|
||||||
|
|
||||||
# yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
|
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
|
||||||
#
|
|
||||||
# if yearmonth == '':
|
if yearmonth == '':
|
||||||
# date = dateutils.add_months(datetime.today(), months=-1)
|
date = dateutils.add_months(datetime.today(), months=-1)
|
||||||
# yearmonth = int(dateutils.format_date(date, '%Y%m'))
|
yearmonth = int(dateutils.format_date(date, '%Y%m'))
|
||||||
# try:
|
try:
|
||||||
# for city in areautils.get_all_cities():
|
for city in areautils.get_all_cities():
|
||||||
# calc(city, yearmonth)
|
calc(city, yearmonth)
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# log.error(e)
|
log.error(e)
|
||||||
|
|
||||||
# # 初始化从2024年9月
|
# # 初始化从2024年9月
|
||||||
# 创建从2024年9月到2024年12月的日期范围
|
# 创建从2024年9月到2024年12月的日期范围
|
||||||
date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M')
|
# date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M')
|
||||||
|
#
|
||||||
# 创建一个包含这些日期的DataFrame
|
# # 创建一个包含这些日期的DataFrame
|
||||||
df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)})
|
# df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)})
|
||||||
|
#
|
||||||
# 将日期设置为索引
|
# # 将日期设置为索引
|
||||||
df.set_index('date', inplace=True)
|
# df.set_index('date', inplace=True)
|
||||||
|
#
|
||||||
# 遍历DataFrame
|
# # 遍历DataFrame
|
||||||
for city in areautils.get_all_cities():
|
# for city in areautils.get_all_cities():
|
||||||
for date, row in df.iterrows():
|
# for date, row in df.iterrows():
|
||||||
try:
|
# try:
|
||||||
date_format = int(dateutils.format_date(date, '%Y%m'))
|
# date_format = int(dateutils.format_date(date, '%Y%m'))
|
||||||
calc(city, date_format)
|
# calc(city, date_format)
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
log.error(e)
|
# log.error(e)
|
||||||
|
|||||||
+26
-26
@@ -81,32 +81,32 @@ def calc(city, year_month):
|
|||||||
log.info(f"{city} {year_month} 均价计算完毕!")
|
log.info(f"{city} {year_month} 均价计算完毕!")
|
||||||
|
|
||||||
|
|
||||||
# yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
|
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
|
||||||
#
|
|
||||||
# if yearmonth == '':
|
if yearmonth == '':
|
||||||
# date = dateutils.add_months(datetime.today(), months=-1)
|
date = dateutils.add_months(datetime.today(), months=-1)
|
||||||
# yearmonth = int(dateutils.format_date(date, '%Y%m'))
|
yearmonth = int(dateutils.format_date(date, '%Y%m'))
|
||||||
# try:
|
try:
|
||||||
# for city in areautils.get_all_cities():
|
for city in areautils.get_all_cities():
|
||||||
# calc(city, yearmonth)
|
calc(city, yearmonth)
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# log.error(e)
|
log.error(e)
|
||||||
|
|
||||||
# # 初始化从2024年9月
|
# # 初始化从2024年9月
|
||||||
# 创建从2024年9月到2024年12月的日期范围
|
# 创建从2024年9月到2024年12月的日期范围
|
||||||
date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M')
|
# date_range = pd.date_range(start='2024-09-01', end='2025-02-28', freq='M')
|
||||||
|
#
|
||||||
# 创建一个包含这些日期的DataFrame
|
# # 创建一个包含这些日期的DataFrame
|
||||||
df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)})
|
# df = pd.DataFrame({'date': date_range, 'value': range(1, len(date_range) + 1)})
|
||||||
|
#
|
||||||
# 将日期设置为索引
|
# # 将日期设置为索引
|
||||||
df.set_index('date', inplace=True)
|
# df.set_index('date', inplace=True)
|
||||||
|
#
|
||||||
# 遍历DataFrame
|
# # 遍历DataFrame
|
||||||
for city in areautils.get_all_cities():
|
# for city in areautils.get_all_cities():
|
||||||
for date, row in df.iterrows():
|
# for date, row in df.iterrows():
|
||||||
try:
|
# try:
|
||||||
date_format = int(dateutils.format_date(date, '%Y%m'))
|
# date_format = int(dateutils.format_date(date, '%Y%m'))
|
||||||
calc(city, date_format)
|
# calc(city, date_format)
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
log.error(e)
|
# log.error(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user