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

Проблема с Timestamp #64

Open
RomanS2N opened this issue Jan 17, 2023 · 1 comment
Open

Проблема с Timestamp #64

RomanS2N opened this issue Jan 17, 2023 · 1 comment

Comments

@RomanS2N
Copy link

Почему-то скрипту январские праздники не нравятся:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\base.py", line 3803, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pandas\_libs\index.pyx", line 516, in pandas._libs.index.DatetimeEngine.get_loc
  File "pandas\_libs\index.pyx", line 550, in pandas._libs.index.DatetimeEngine.get_loc
KeyError: Timestamp('2022-01-04 00:00:00')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\datetimes.py", line 736, in get_loc
    return Index.get_loc(self, key, method, tolerance)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\base.py", line 3805, in get_loc
    raise KeyError(key) from err
KeyError: Timestamp('2022-01-04 00:00:00')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\investments\ibtax\__main__.py", line 3, in <module>
    main()
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\investments\ibtax\ibtax.py", line 307, in main
    fees_report = prepare_fees_report(fees, cbr_client_usd, args.verbose) if fees else None
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\investments\ibtax\ibtax.py", line 94, in prepare_fees_report
    df['rate'] = df.apply(lambda x: cbr_client_usd.get_rate(x['amount'].currency, x[operation_date_column]), axis=1)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\frame.py", line 9565, in apply
    return op.apply().__finalize__(self, method="apply")
           ^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\apply.py", line 746, in apply
    return self.apply_standard()
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\apply.py", line 873, in apply_standard
    results, res_index = self.apply_series_generator()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\apply.py", line 889, in apply_series_generator
    results[i] = self.f(v)
                 ^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\investments\ibtax\ibtax.py", line 94, in <lambda>
    df['rate'] = df.apply(lambda x: cbr_client_usd.get_rate(x['amount'].currency, x[operation_date_column]), axis=1)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\investments\data_providers\cbr.py", line 41, in get_rate
    return rates.loc[dt].item()
           ~~~~~~~~~^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexing.py", line 1073, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexing.py", line 1312, in _getitem_axis
    return self._get_label(key, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexing.py", line 1260, in _get_label
    return self.obj.xs(label, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\generic.py", line 4056, in xs
    loc = index.get_loc(key)
          ^^^^^^^^^^^^^^^^^^
  File "C:\Users\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\datetimes.py", line 738, in get_loc
    raise KeyError(orig_key) from err
KeyError: Timestamp('2022-01-04 00:00:00')

@RomanS2N
Copy link
Author

tolerance = 'None'
method = 'None'
Key = Timestamp('2022-01-04 00:00:00')
Self = DatetimeIndex(['2022-01-11', '2022-01-12', '2022-01-13', '2022-01-14',
'2022-01-15', '2022-01-16', '2022-01-17', '2022-01-18',
'2022-01-19', '2022-01-20',
...
'2023-01-10', '2023-01-11', '2023-01-12', '2023-01-13',
'2023-01-14', '2023-01-15', '2023-01-16', '2023-01-17',
'2023-01-18', '2023-01-19'],
dtype='datetime64[ns]', length=374, freq='D')

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

No branches or pull requests

1 participant