from datetime import timedelta
num = pd.read_excel('结果.xlsx', sheet_name='初日')
num = np.array(num)
date_num = np.zeros([60, 346])
date_pd = pd.DataFrame(np.zeros([60, 345]))
for row in range(3, 63):
for col in range(1, np.size(num, 1)):
t0 = datetime.date(2021, 1, 1)
if num[row, col] != 0:
days = t0 + timedelta(num[row, col] - 1)
date_num[row - 3, col] = int(days.strftime('%m%d'))
strnum = str(days.strftime('%m%d'))
date_pd[col-1][row - 3]=(strnum[0:2]+'月'+strnum[2:5]+'日')
else:
date_num[row - 3, col] = np.nan
date_pd[col-1][row - 3]= "--"
df = pd.DataFrame(date_pd)
df.to_clipboard(index=False, header=False)
|