Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas datetools module error

I'm trying to call a module from pandas datetools, but am getting an error that the mofule object has no attribute by the name I'm calling. Wondering if anyone can shed some light on this issue. Below is the code I am trying to use:

import blpapi
import pandas as pd
from tia.bbg import LocalTerminal
import datetime
from pandas import datetools

sid = 'BKLN US EQUITY'
events = ['TRADE','AT_TRADE']
dt = pd.datetools.BDAY(-1).apply(pd.datetime.now())

And here is the error I am facing:

Traceback (most recent call last):
File "C:\bb_test.py", line 14, in <module>
dt = pd.datetools.BDAY(-1).apply(pd.datetime.now())
File "C:\Python27\lib\site-packages\pandas\util\_depr_module.py", line 61, in 
__getattr__
obj = getattr(deprmodule, name)
AttributeError: 'module' object has no attribute 'BDAY'
like image 891
jod51 Avatar asked Apr 19 '26 22:04

jod51


1 Answers

First, consider that pandas datetools is deprecated and will be removed in future releases.

But if you insist on using it, you need to pass timedelta object to bday function like follows:

import pandas as pd
from pandas import datetools
import datetime
from datetime import timedelta

# Constructing timedelta object 
d = timedelta(days=-1)
# passing it to bday
pd.datetools.bday(d).apply(pd.datetime.now())
like image 98
Mark K. Avatar answered Apr 21 '26 10:04

Mark K.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!