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

AttributeError: module 'pandas.core.ops' #248

Closed
mboldin opened this issue Sep 3, 2022 · 3 comments
Closed

AttributeError: module 'pandas.core.ops' #248

mboldin opened this issue Sep 3, 2022 · 3 comments

Comments

@mboldin
Copy link

mboldin commented Sep 3, 2022

I am running on Windows 10 Intel i5
and get import error with

import pandas as pd
import text_extensions_for_pandas as tp
when run in Jupyter Notebook

the relevant error code is
AttributeError: module 'pandas.core.ops' has no attribute '_get_op_name'

imports worked 6 weeks ago fail now and
I have no problem with import text_extensions_for_pandas not in Jupyter
I tried to create a virtenv just for this problem and installed full pip install of pandas, text_extensions_for_pandas and jupyter
and I see the same error only in Jupyter
see ERROR in context for more detail

Versions
pandas 1.3.5

and
Selected Jupyter core packages...
IPython : 7.34.0
ipykernel : 6.15.2
ipywidgets : 8.0.2
jupyter_client : 7.3.5
jupyter_core : 4.11.1
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.6.7
nbconvert : 7.0.0
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : 5.3.2
traitlets : 5.3.0

I am not 100% sure of the text_extensions_for_pandas versions maybe 0.2.0

(text_pandas) C:\Users\mdbol\Desktop\virtenv\text_pandas>pip install text_extensions_for_pandas
Collecting text_extensions_for_pandas
Using cached text_extensions_for_pandas-0.2.0-py3-none-any.whl (199 kB)


ERROR In context:
~\AppData\Local\Programs\Python\Python37\lib\site-packages\text_extensions_for_pandas\array_init_.py in
25 from text_extensions_for_pandas.array.char_span import *
26 from text_extensions_for_pandas.array.token_span import *
---> 27 from text_extensions_for_pandas.array.tensor import *
28 from text_extensions_for_pandas.array.accessor import *
29

~\AppData\Local\Programs\Python\Python37\lib\site-packages\text_extensions_for_pandas\array\tensor.py in
281
282 # Add operators from the mixin to the class
--> 283 TensorArray._add_arithmetic_ops()
284 TensorArray._add_comparison_ops()

~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\arrays\base.py in _add_arithmetic_ops(cls)
1342 @classmethod
1343 def _add_arithmetic_ops(cls):
-> 1344 setattr(cls, "add", cls._create_arithmetic_method(operator.add))
1345 setattr(cls, "radd", cls._create_arithmetic_method(ops.radd))
1346 setattr(cls, "sub", cls._create_arithmetic_method(operator.sub))

~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\arrays\base.py in _create_arithmetic_method(cls, op)
1495 @classmethod
1496 def _create_arithmetic_method(cls, op):
-> 1497 return cls._create_method(op)
1498
1499 @classmethod

~\AppData\Local\Programs\Python\Python37\lib\site-packages\text_extensions_for_pandas\array\tensor.py in _create_method(cls, op, coerce_to_dtype)
92 return TensorArray(res)
93
---> 94 op_name = ops._get_op_name(op, True)
95 return set_function_name(_binop, op_name, cls)
96

AttributeError: module 'pandas.core.ops' has no attribute '_get_op_name'

@mboldin
Copy link
Author

mboldin commented Sep 4, 2022

UPDATE:

Looking at the Jupyter consoile output, I see:

[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.control
[IPKernelApp] WARNING | No such comm: 86364858-6645-43b9-8ee3-3f3405095abe

when import text_extensions_for_pandas fails

A Google search of this error string shows it has been reported for other packages (not text_extensions_for_pandas)
as a result of problems related to ipywidgets see jupyter-widgets/ipywidgets#2257

So I doubt it is a fixable TEXT_EXTENSIONS_FOR_PANDAS
I will close this issue in a few days if this diagnosis is right, and in meantime hope someone report here a workaround.

@mboldin
Copy link
Author

mboldin commented Sep 4, 2022

FIXED -- for me
My jupyter run was pointing to an old pre-alpha version of text_extensions_for_pandas
I deleted this, and forced a new install of he module and all is OK
The bad line
---> 94 op_name = ops._get_op_name(op, True)
was from an old version of tensor.py
the latest 0.2.0 version has different code logic for
def _create_method(cls, op, coerce_to_dtype=True, result_dtype=None):

@mboldin mboldin closed this as completed Sep 4, 2022
@frreiss
Copy link
Member

frreiss commented Sep 6, 2022

Glad this issue is resolved for you now. Let us know if you have any other problems.

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

2 participants