Skip to content
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

Pandas error when running the single stock example #300

Closed
fretchen opened this issue May 19, 2016 · 16 comments
Closed

Pandas error when running the single stock example #300

fretchen opened this issue May 19, 2016 · 16 comments

Comments

@fretchen
Copy link

Hi, I am running the single stock example. As I run the line:

pf.create_returns_tear_sheet(stock_rets, live_start_date='2015-12-1')

I obtain the following error:

/lib/python3.4/site-packages/pandas/tseries/tools.py in _convert_listlike(arg, box, format, name)
329 arg = getattr(arg, 'values', arg)
330 result = tslib.array_with_unit_to_datetime(arg, unit,
--> 331 errors=errors)
332 if box:
333 if errors == 'ignore':
pandas/tslib.pyx in pandas.tslib.array_with_unit_to_datetime (pandas/tslib.c:38273)()
pandas/tslib.pyx in pandas.tslib.array_with_unit_to_datetime (pandas/tslib.c:37194)()
ValueError: non convertible value 2015-07-21with the unit 'D'

@justinlent
Copy link
Contributor

@fretchen This is likely do to the version of pandas. What version are you on?

@fretchen
Copy link
Author

Hi, I run it with pandas 0.18.1 . I might try to downgrade pandas to test the version issue, but am not sure yet how this is typically done.

@twiecki
Copy link
Contributor

twiecki commented May 23, 2016

We should support 0.18.1 so I'll mark this as a bug, thanks for reporting.

@fretchen
Copy link
Author

fretchen commented May 24, 2016

Ok, I tried to convert it back to version 0.18.0 and there I do not get any error messages.

@twiecki
Copy link
Contributor

twiecki commented May 25, 2016

I can run single_stock_example.ipynb in the examples dir fine with 0.18.1. In any case it seems to be working for you now so I'm closing this. Please reopen if the problem resurfaces.

@twiecki twiecki closed this as completed May 25, 2016
@saeedamen
Copy link

saeedamen commented May 31, 2016

I appear to get a similar error

fig = pf.create_returns_tear_sheet(stock_rets, return_fig=True)

File "C:\Anaconda3-64\lib\site-packages\pyfolio\plotting.py", line 49, in call_w_context
return func(_args, *_kwargs)
File "C:\Anaconda3-64\lib\site-packages\pyfolio\tears.py", line 356, in create_returns_tear_sheet
returns, top=5, ax=ax_drawdown)
File "C:\Anaconda3-64\lib\site-packages\pyfolio\plotting.py", line 406, in plot_drawdown_periods
df_drawdowns = timeseries.gen_drawdown_table(returns, top=top)
File "C:\Anaconda3-64\lib\site-packages\pyfolio\timeseries.py", line 1072, in gen_drawdown_table
unit='D')
File "C:\Anaconda3-64\lib\site-packages\pandas\util\decorators.py", line 91, in wrapper
return func(_args, *_kwargs)
File "C:\Anaconda3-64\lib\site-packages\pandas\tseries\tools.py", line 291, in to_datetime
unit=unit, infer_datetime_format=infer_datetime_format)
File "C:\Anaconda3-64\lib\site-packages\pandas\tseries\tools.py", line 420, in _to_datetime
values = _convert_listlike(arg._values, False, format)
File "C:\Anaconda3-64\lib\site-packages\pandas\tseries\tools.py", line 331, in _convert_listlike
errors=errors)
File "pandas\tslib.pyx", line 1981, in pandas.tslib.array_with_unit_to_datetime (pandas\tslib.c:38273)
File "pandas\tslib.pyx", line 2071, in pandas.tslib.array_with_unit_to_datetime (pandas\tslib.c:37194)
ValueError: non convertible value 2015-07-21with the unit 'D'

where stock_rets = pf.utils.get_symbol_rets('FB') (thought it was initially issue with the date format, but not sure if that's the case)

I'm using Pandas 0.18.1

@twiecki twiecki reopened this May 31, 2016
@twiecki
Copy link
Contributor

twiecki commented Jun 7, 2016

Hm, I still can't reproduce. Can you show the output of

import pandas
pandas.util.print_versions.show_versions()

Mine is:



INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-22-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 21.2.1
Cython: 0.24
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.2.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.7
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext)
jinja2: 2.8
boto: 2.40.0
pandas_datareader: 0.2.1

@saeedamen
Copy link

saeedamen commented Jun 8, 2016

Here is my output

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.1
setuptools: 20.3
Cython: 0.23.4
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: 0.2.1

@twiecki
Copy link
Contributor

twiecki commented Jun 8, 2016

The thing I notice is numpy: 1.11.0. Which I don't seem to get via anaconda yet. Can you try with an environment that uses numpy 1.10?

@knajimi
Copy link

knajimi commented Jun 9, 2016

Just upgraded pyfolio to 0.5.0 and pandas to 0.18.1 and am now getting the same error. Also using numpy 1.11.0.

@twiecki
Copy link
Contributor

twiecki commented Jun 9, 2016

I upgraded to numpy 1.11.0 and still can't reproduce.
Can you try upgrading to pyfolio master?

@twiecki
Copy link
Contributor

twiecki commented Jun 9, 2016

Potentially #297 fixed it.

@abhijeetkalyan
Copy link
Contributor

I ran into this same issue when using pyfolio 0.5.0. The fix was to upgrade to pyfolio master, via:

pip install git+https://github.com/quantopian/pyfolio.git

for reference, this is what the relevant line of pip freeze looks like now:

pyfolio==0.5.0+24.g8d8ddf1

This is in a virtualenv using pandas 0.18.1 and numpy 1.11.0.

@twiecki
Copy link
Contributor

twiecki commented Jun 9, 2016

Thanks @abhijeetkalyan. We'll release a 0.5.1 soon that should have the fix.

@knajimi
Copy link

knajimi commented Jun 9, 2016

upgrade to master worked for me. thx!

@twiecki
Copy link
Contributor

twiecki commented Jun 10, 2016

OK, I released a 0.5.1 to fix this behavior: http://quantopian.github.io/pyfolio/whatsnew/#v051-june-10-2016

@twiecki twiecki closed this as completed Jun 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants