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

TypeError: 'Timestamp' object is not subscriptable #3

Closed
aaguiar10 opened this issue Aug 31, 2023 · 1 comment
Closed

TypeError: 'Timestamp' object is not subscriptable #3

aaguiar10 opened this issue Aug 31, 2023 · 1 comment

Comments

@aaguiar10
Copy link
Owner

          Hi There, thanks for the correction, it is greatly appreciated. apparently there is something with Timestamp, it does not let the csv load.

Dash is running on http://127.0.0.1:8050/

  • Serving Flask app 'my_app'
  • Debug mode: off
    WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Running on http://127.0.0.1:8050
    Press CTRL+C to quit
    127.0.0.1 - - [31/Aug/2023 09:25:01] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [31/Aug/2023 09:25:01] "GET /assets/style.css?m=1693452280.0 HTTP/1.1" 304 -
    127.0.0.1 - - [31/Aug/2023 09:25:01] "GET /_dash-layout HTTP/1.1" 200 -
    127.0.0.1 - - [31/Aug/2023 09:25:01] "GET /_dash-dependencies HTTP/1.1" 200 -
    127.0.0.1 - - [31/Aug/2023 09:25:01] "GET /_favicon.ico?v=2.13.0 HTTP/1.1" 200 -
    127.0.0.1 - - [31/Aug/2023 09:25:02] "POST /_dash-update-component HTTP/1.1" 200 -
    127.0.0.1 - - [31/Aug/2023 09:25:02] "POST /_dash-update-component HTTP/1.1" 200 -
    127.0.0.1 - - [31/Aug/2023 09:25:02] "GET /_dash-component-suites/dash/dcc/async-dropdown.js HTTP/1.1" 304 -
    127.0.0.1 - - [31/Aug/2023 09:25:02] "GET /_dash-component-suites/dash/dcc/async-graph.js HTTP/1.1" 304 -
    127.0.0.1 - - [31/Aug/2023 09:25:02] "GET /assets/cup.webp HTTP/1.1" 304 -
    127.0.0.1 - - [31/Aug/2023 09:25:02] "GET /_dash-component-suites/plotly/package_data/plotly.min.js HTTP/1.1" 304 -
    [2023-08-31 09:25:03,146] ERROR in app: Exception on /dash-update-component [POST]
    Traceback (most recent call last):
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
    ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\dash\dash.py", line 1297, in dispatch
    ctx.run(
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\dash_callback.py", line 437, in add_context
    output_value = func(*func_args, **func_kwargs) # %% callback invoked %%
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\Downloads\gflows-main\gflows-main\my_app.py", line 188, in update_live_chart
    ) = query_data(stock, expiration)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask_caching_init
    .py", line 877, in decorated_function
    rv = self.call_fn(f, *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask_caching_init
    .py", line 180, in call_fn
    return ensure_sync(fn)(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\Downloads\gflows-main\gflows-main\my_app.py", line 53, in query_data
    result = getOptionsData(ticker, expir)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\Downloads\gflows-main\gflows-main\calc.py", line 205, in getOptionsData
    thisMonthlyOpex, calendarRange = isThirdFriday(firstExpiry)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\cachetools_init
    .py", line 737, in wrapper
    v = func(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\Downloads\gflows-main\gflows-main\calc.py", line 77, in isThirdFriday
    result = mcal.get_calendar("NYSE").schedule(start_date=first, end_date=last)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas_market_calendars\market_calendar.py", line 616, in schedule
    special = self.special_dates(market_time, start_date, end_date, filter_holidays= False)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas_market_calendars\market_calendar.py", line 557, in special_dates
    special = self._special_dates(calendars, ad_hoc, start_date, end_date)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas_market_calendars\market_calendar.py", line 531, in _special_dates
    indexes = [
    ^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas_market_calendars\market_calendar.py", line 532, in
    self.days_at_time(self.tryholidays(calendar, start, end), time)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas_market_calendars\market_calendar.py", line 521, in _tryholidays
    try: return cal.holidays(s, e)
    ^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\tseries\holiday.py", line 476, in holidays
    pre_holidays = [
    ^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\tseries\holiday.py", line 477, in
    rule.dates(start, end, return_name=True) for rule in self.rules
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\tseries\holiday.py", line 283, in dates
    holiday_dates = self._apply_rule(dates)
    ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\tseries\holiday.py", line 360, in _apply_rule
    return dates.map(lambda d: self.observance(d))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\indexes\base.py", line 6418, in map
    new_values = self._map_values(mapper, na_action=na_action)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\base.py", line 919, in _map_values
    return arr.map(mapper, na_action=na_action)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\arrays_mixins.py", line 80, in method
    return meth(self, *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\arrays\datetimelike.py", line 722, in map
    result = map_array(self, mapper, na_action=na_action)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\algorithms.py", line 1812, in map_array
    return lib.map_infer(values, mapper, convert=convert)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "lib.pyx", line 2917, in pandas._libs.lib.map_infer
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\tseries\holiday.py", line 360, in
    return dates.map(lambda d: self.observance(d))
    ^^^^^^^^^^^^^^^^^^
    File "C:\Users\Richkidpe 3\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas_market_calendars\holidays_nyse.py", line 306, in july_5th_holiday_observance
    return datetime_index[datetime_index.year < 2013]
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'Timestamp' object is not subscriptable
    127.0.0.1 - - [31/Aug/2023 09:25:03] "POST /_dash-update-component HTTP/1.1" 500 -

Originally posted by @richkidpe in #2 (comment)

@aaguiar10
Copy link
Owner Author

aaguiar10 commented Aug 31, 2023

@richkidpe,

Pandas v2.1.0 (released Aug 30, 2023) breaks one of the dependencies rsheftel/pandas_market_calendars#279 (currently v4.2.1), so in the meantime you can downgrade pandas to v2.0.3 until the dev fixes the issue.

$ pip install --upgrade pandas==2.0.3

@aaguiar10 aaguiar10 pinned this issue Aug 31, 2023
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