Мне нужно составить ежемесячную сумму объемов акций за каждый месяц с 2000 по 2019. Сейчас у меня есть этот код:
yearList = [j for j in range(2001,2020)]
yearsplits= np.searchsorted(years, yearList)
volumeYears=np.searchsorted(sp_volume, yearsplits)
for j in range(19):
print(" {}: {:12.0f}".format(j+2000, volumeYears[j].sum()))
months = dates.astype('datetime64[M]').astype(int) # this is a sequence increasing by 1 every month
months -= months[0] #to skip the months before 1/1/2000
monthsplits = np.searchsorted(months, range(1, 19*12+2))
# from 1/1/2000 to 12/31/2018 are 19years * 12months, and Jan,Feb 2019 at the end
volumeMonths=np.searchsorted(sp_volume, monthsplits)
for j in range(19):
print(" {}: {:12.0f}".format(j+2000, volumeMonths[j].sum()))
но volumeMonths
и volumeYears
возвращают все нули, что приводит к тому, что volumeMonths.sum()
и volumeYears.sum()
также возвращают нули. Как получить фактическую сумму объемов за каждый месяц?