Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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'

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())
                Thank you! I'm aware of datetools being deprecated - do you have any suggestions as to what I could use in it's place in this scenario?
– jod51
                Jun 19, 2018 at 15:28
                I didn't exactly get the scenario, I'm not sure what is the usage of  sid and events, but if you're looking for a function to return datetime of yesterday in pythonic format you can easily use datetime module like this: now = datetime.datetime.now() print "yesterday: ", now - datetime.timedelta(days=-1)
– Mark K.
                Jun 19, 2018 at 15:41
                I am pulling financial data from a bloomberg terminal using packages named blpapi & tia (sid and events are just identifiers to be used later here) - but in particular, yes, I was just looking for another function to pull datetime of yesterday. Appreciate the help!
– jod51
                Jun 19, 2018 at 17:00
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.