Skip to content

'Series' object has no attribute 'freqstr' in example 9 (Period index and Period column) in binder launch example #274

@hanfried

Description

@hanfried

Environment

  • Operating System: Linux 4.14.127+
  • Python Version: $ python --version 3.7.2
  • How did you install Qgrid: (pip, conda, or other (please explain)) used the linked binder.org version from github in the README
  • Python packages: $ pip freeze or $ conda list (please include qgrid, notebook, and jupyterlab versions)
    alembic==1.0.8
    asn1crypto==0.24.0
    async-generator==1.10
    attrs==19.1.0
    backcall==0.1.0
    bleach==3.1.0
    certifi==2019.3.9
    cffi==1.11.5
    chardet==3.0.4
    conda==4.5.11
    cryptography==2.6.1
    cycler==0.10.0
    decorator==4.4.0
    defusedxml==0.5.0
    entrypoints==0.3
    idna==2.8
    ipykernel==5.1.0
    ipython==7.4.0
    ipython-genutils==0.2.0
    ipywidgets==7.4.2
    jedi==0.13.3
    Jinja2==2.10
    jsonschema==3.0.1
    jupyter-client==5.2.4
    jupyter-core==4.4.0
    jupyterhub==0.9.4
    jupyterlab==0.35.4
    jupyterlab-server==0.2.0
    kiwisolver==1.0.1
    lxml==4.3.3
    Mako==1.0.8
    MarkupSafe==1.1.1
    matplotlib==3.0.3
    mistune==0.8.4
    nbconvert==5.4.1
    nbformat==4.4.0
    notebook==5.7.6
    nteract-on-jupyter==2.0.0
    numpy==1.16.2
    pamela==1.0.0
    pandas==0.24.2
    pandas-datareader==0.7.0
    pandocfilters==1.4.2
    parso==0.3.4
    pexpect==4.6.0
    pickleshare==0.7.5
    prometheus-client==0.6.0
    prompt-toolkit==2.0.9
    ptyprocess==0.6.0
    pycosat==0.6.3
    pycparser==2.18
    Pygments==2.3.1
    pyOpenSSL==18.0.0
    pyparsing==2.3.1
    pyrsistent==0.14.11
    PySocks==1.6.8
    python-dateutil==2.8.0
    python-editor==1.0.4
    python-oauth2==1.1.0
    pytz==2018.9
    pyzmq==18.0.1
    qgrid==1.1.1
    requests==2.21.0
    ruamel-yaml==0.15.46
    Send2Trash==1.5.0
    six==1.12.0
    SQLAlchemy==1.3.1
    terminado==0.8.1
    testpath==0.4.2
    tornado==6.0.1
    traitlets==4.3.2
    urllib3==1.24.1
    wcwidth==0.1.7
    webencodings==0.5.1
    widgetsnbextension==3.4.2
    wrapt==1.11.1
  • Jupyter lab packages (if applicable): $ jupyter labextension list
    JupyterLab v0.35.4
    Known labextensions:
    app dir: /srv/conda/share/jupyter/lab
    @jupyter-widgets/jupyterlab-manager v0.38.1 enabled OK
    qgrid v1.1.1 enabled OK

Description of Issue

  • What did you expect to happen?

That all examples in the linked demo launched notebook on binder.org works unless I change something.

  • What happened instead?

Example 9 throws AttributeError 'Series' object has no attribute 'freqstr' and the stacktrace shows it's an internal problem:


AttributeError Traceback (most recent call last)
in
3 range_index = pd.period_range(start='2000', periods=10, freq='B')
4 df = pd.DataFrame({'a': 5, 'b': range_index}, index=range_index)
----> 5 view = qgrid.show_grid(df)
6 view

/srv/conda/lib/python3.7/site-packages/qgrid/grid.py in show_grid(data_frame, show_toolbar, precision, grid_options, column_options, column_definitions, row_edit_callback)
509 column_definitions=column_definitions,
510 row_edit_callback=row_edit_callback,
--> 511 show_toolbar=show_toolbar)
512
513

/srv/conda/lib/python3.7/site-packages/qgrid/grid.py in init(self, *args, **kwargs)
625
626 if self.df is not None:
--> 627 self._update_df()
628
629 def _grid_options_default(self):

/srv/conda/lib/python3.7/site-packages/qgrid/grid.py in _update_df(self)
818 self._unfiltered_df = self._df.copy()
819
--> 820 self._update_table(update_columns=True, fire_data_change_event=False)
821 self._ignore_df_changed = False
822

/srv/conda/lib/python3.7/site-packages/qgrid/grid.py in _update_table(self, update_columns, triggered_by, scroll_to_row, fire_data_change_event)
961 orient='table',
962 date_format='iso',
--> 963 double_precision=self.precision)
964
965 if update_columns:

/srv/conda/lib/python3.7/site-packages/pandas/io/json/json.py in to_json(path_or_buf, obj, orient, date_format, double_precision, force_ascii, date_unit, default_handler, lines, compression, index)
60 double_precision=double_precision, ensure_ascii=force_ascii,
61 date_unit=date_unit, default_handler=default_handler,
---> 62 index=index).write()
63
64 if lines:

/srv/conda/lib/python3.7/site-packages/pandas/io/json/json.py in init(self, obj, orient, date_format, double_precision, ensure_ascii, date_unit, index, default_handler)
184 raise ValueError(msg)
185
--> 186 self.schema = build_table_schema(obj, index=self.index)
187
188 # NotImplementd on a column MultiIndex

/srv/conda/lib/python3.7/site-packages/pandas/io/json/table_schema.py in build_table_schema(data, index, primary_key, version)
242 if data.ndim > 1:
243 for column, s in data.iteritems():
--> 244 fields.append(convert_pandas_type_to_json_field(s))
245 else:
246 fields.append(convert_pandas_type_to_json_field(data))

/srv/conda/lib/python3.7/site-packages/pandas/io/json/table_schema.py in convert_pandas_type_to_json_field(arr, dtype)
109 field['ordered'] = ordered
110 elif is_period_dtype(arr):
--> 111 field['freq'] = arr.freqstr
112 elif is_datetime64tz_dtype(arr):
113 if hasattr(arr, 'dt'):

/srv/conda/lib/python3.7/site-packages/pandas/core/generic.py in getattr(self, name)
5065 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5066 return self[name]
-> 5067 return object.getattribute(self, name)
5068
5069 def setattr(self, name, value):

AttributeError: 'Series' object has no attribute 'freqstr'

Reproduction Steps

  1. Open https://github.com/quantopian/qgrid
  2. Click on launch binder (directs me to https://mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?filepath=index.ipynb)
  3. Click on Run all cells (or just run the cell with the code for Example 9)
    ...

What steps have you taken to resolve this already?

None, it's the introductionary example - should work for beginners :-)
...

Anything else?

Anyway, love it, even if it does not work on Period index and Period column
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions