Skip to content

dealing with OANDA returning strings for currency above 1000 #293

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

Closed
wants to merge 2 commits into from

Conversation

STguerin
Copy link

@STguerin STguerin commented Apr 3, 2017

simple 2 line add for converting all strings above 1000 to float. I first remove all the , and the convert to float64

try pulling this currency pair:

base_currency = "KRW'
quote_currency ='USD'

  File "C:\Anaconda2\lib\site-packages\pandas_datareader\oanda.py", line 52, in get_oanda_currency_historical_rates
    df = 1 / df
  File "C:\Anaconda2\lib\site-packages\pandas\core\ops.py", line 1097, in f
    return self._combine_const(other, na_op)
  File "C:\Anaconda2\lib\site-packages\pandas\core\frame.py", line 3555, in _combine_const
    raise_on_error=raise_on_error)
  File "C:\Anaconda2\lib\site-packages\pandas\core\internals.py", line 2911, in eval
    return self.apply('eval', **kwargs)
  File "C:\Anaconda2\lib\site-packages\pandas\core\internals.py", line 2890, in apply
    applied = getattr(b, f)(**kwargs)
  File "C:\Anaconda2\lib\site-packages\pandas\core\internals.py", line 1139, in eval
    result = handle_error()
  File "C:\Anaconda2\lib\site-packages\pandas\core\internals.py", line 1123, in handle_error
    (repr(other), str(detail)))
TypeError: Could not operate 1 with block values unsupported operand type(s) for /: 'int' and 'str'


… example ) coverting those object dtype to float64 type.
@femtotrader
Copy link
Contributor

Could you first open an issue to show with some sample code what is wrong?
It will also help to write unit tests

@femtotrader
Copy link
Contributor

Closes #294

@femtotrader
Copy link
Contributor

read_csv have a parameter named thousands
see http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html#pandas-read-csv

thousands : str, default None
Thousands separator

@STguerin
Copy link
Author

STguerin commented Apr 4, 2017

you are right, that's even better!

Copy link
Author

@STguerin STguerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works perfectly

@femtotrader
Copy link
Contributor

Nice!
But this branch is protected against PR that don't pass unit tests and so I can't merge even if I know what you did is correct.
this is not your fault @STguerin
We first need to fix other tests before accepting this PR
see #295

@jreback
Copy link
Contributor

jreback commented Jul 2, 2017

can you rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants