I'm getting a class typeerror using dateutil's relative delta. My code is here:
#import packages
import numpy as np
import pandas as pd
import datetime as dt
from dateutil.relativedelta import relativedelta
from pandas import DataFrame
from pandas import Series
#timing
pers = 12
monthpp = 1
month_per = int(pers/monthpp)
sdate = dt.date(2016,1,1)
ops = dt.date(2016,3,15)
bop1 = sdate
eop1 = bop1 + relativedelta(months =+ 1, days =- 1)
edate = sdate + relativedelta(months =+ month_per)
rng_bop = pd.date_range(bop1, freq = 'MS', periods = pers)
rng_eop = pd.date_range(eop1, freq = 'M', periods = pers)
ops_line = ops >= rng_bop and ops <= rng_eop
#outputs
print(sdate)
print(edate)
print(rng_bop)
print(rng_eop)
If someone has a better alternative to my method, I'd be open to it - I'm trying to translate excel stuff into python and might not be doing it super effectively.
My end goal for this part is to be able to adjust the period by months, quarters or semi-annual or years, but I'd be happy with just months for now. The EOP line should be the (BOP + Period - 1 day).
I also don't think that my ops_line definition will work - I'm trying to create a boolean array from the logical operators. Any points?