-
Notifications
You must be signed in to change notification settings - Fork 679
[ENH] Fama/French #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a7ca65c
to
b69c110
Compare
except: pass | ||
try: return dt.datetime.strptime(x, '%Y%m') | ||
except: pass | ||
return to_datetime(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks terrible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of any other way to do that unless we import dateutil.
4d0f191
to
665a1c7
Compare
root = BeautifulSoup(socket.read(), 'html.parser') | ||
|
||
l = filter(lambda x: x.startswith(_FF_PREFIX) and x.endswith(_FF_SUFFIX), | ||
[e.attrs['href'] for e in root.findAll('a') if 'href' in e.attrs]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any substitute for findAll
which does not involve any import ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a dependency on lxml, so maybe use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this gist out:
https://gist.github.com/yejianye/5895954
Also, we could pull the Options._parse_url method out into a common function, as it does the importing and error checking for lxml.
@davidastephens done |
Thanks. We will need to rebase/squash after #69 is merged, but other than that, looks good to me. |
#69 merged, can you rebase? |
Done I also added a test which fails on python 2.6. >>> df[0].to_period()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/python/2.6.9/lib/python2.6/site-packages/pandas/core/frame.py", line 4258, in to_period
freq = self.index.freqstr or self.index.inferred_freq
File "/opt/python/2.6.9/lib/python2.6/site-packages/pandas/tseries/index.py", line 1393, in freqstr
return self.offset.freqstr
AttributeError: 'NoneType' object has no attribute 'freqstr'
>>> df[0].to_period('M')
Mkt-RF SMB HML RF
1926-07 2.96 -2.30 -2.87 0.22
1926-08 2.64 -1.40 4.19 0.25
1926-09 0.36 -1.32 0.01 0.23
1926-10 -3.24 0.04 0.51 ...
...
>>> print df[0].to_period.__doc__
Convert DataFrame from DatetimeIndex to PeriodIndex with desired
frequency (inferred from index if not passed)
Parameters
----------
freq : string, default
axis : {0, 1}, default 0
The axis to convert (the index by default)
copy : boolean, default True
If False then underlying input data is not copied
Returns
-------
ts : TimeSeries with PeriodIndex |
@jreback @jorisvandenbossche Thoughts? Need to keep supporting pandas 13.1 or move that one to an 'allowed failure'? |
* add get_available_datasets (requires lxml) * complete rewrite of get_data_famafrench
@davidastephens i wrote a workaround for 13.1 |
Thanks! |
ENH: Fama/French re-write.
DESCR
attribute)API change : indexes are now pandas.PeriodIndex for annual and monthly data, and pandas.DatetimeIndex otherwise.
Should fix #55 #20 #21 see also pandas-dev/pandas#8842