ValueError when requesting weekly interest rates
sametsoekel opened this issue · comments
Samet Sökel commented
Hi,
In 0.4.0 version I didn't encounter any problem while getting monthly and daily series but weeklies raise this ValueError:
>>> import tcmb
>>> clien = tcmb.Client(api_key = MY_API_KEY)
>>> clien.read('TP.KTFTUK')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\anaconda3\Lib\site-packages\tcmb\core.py", line 294, in read
df = read(
^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\tcmb\core.py", line 159, in read
data = utils.to_dataframe(res.json()["items"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\tcmb\utils.py", line 71, in to_dataframe
df = df.astype(float)
^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\generic.py", line 6324, in astype
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\internals\managers.py", line 451, in astype
return self.apply(
^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\internals\managers.py", line 352, in apply
applied = getattr(b, f)(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\internals\blocks.py", line 511, in astype
new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\dtypes\astype.py", line 242, in astype_array_safe
new_values = astype_array(values, dtype, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\dtypes\astype.py", line 187, in astype_array
values = _astype_nansafe(values, dtype, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\pandas\core\dtypes\astype.py", line 138, in _astype_nansafe
return arr.astype(dtype, copy=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '1970-1'
Thanks
Turgut Kaymal commented
Hi @sametsoekel, thanks again for the feedback. The reason seems to be non-standard response attributes.
Samet Sökel commented
big thanks for this quick fixes ! when can u push the new release to pypi ?
Turgut Kaymal commented
I've already pushed it. v0.4.1