When I import pandas in jupyter library the following is generated.
AttributeError Traceback (most recent call last)
<ipython-input-24-f869c0f42cc0> in <module>
----> 1 import pandas as pd
2 import numpy as np
3 get_ipython().run_line_magic('matplotlib', 'inline')
C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py in <module>
24
25 try:
---> 26 from pandas._libs import (hashtable as _hashtable,
27 lib as _lib,
28 tslib as _tslib)
pandas\_libs\hashtable_class_helper.pxi in init pandas._libs.hashtable()
AttributeError: type object 'pandas._libs.hashtable.HashTable' has no attribute '__reduce_cython__'
Can you help me in figuring out the problem? Thanks
Use pd at the place of pandas in your code. If you still get error, then write your code also in the question.
Related
I keep trying to import sklearn but I when I do I get the error [ModuleNotFoundError: No module named 'numpy.testing']. I have upgraded numpy, pandas, scipy as well as scikit-learn to the latest versions but I still keep getting the same error. Any idea why. Here is the full error below:
'''
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-152-b7c74cbf5af0> in <module>
----> 1 import sklearn
~\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
80 from . import _distributor_init # noqa: F401
81 from . import __check_build # noqa: F401
---> 82 from .base import clone
83 from .utils._show_versions import show_versions
84
~\anaconda3\lib\site-packages\sklearn\base.py in <module>
15 from . import __version__
16 from ._config import get_config
---> 17 from .utils import _IS_32BIT
18 from .utils._tags import (
19 _DEFAULT_TAGS,
~\anaconda3\lib\site-packages\sklearn\utils\__init__.py in <module>
27 from ..exceptions import DataConversionWarning
28 from .deprecation import deprecated
---> 29 from .fixes import parse_version, threadpool_info
30 from ._estimator_html_repr import estimator_html_repr
31 from .validation import (
~\anaconda3\lib\site-packages\sklearn\utils\fixes.py in <module>
17 import numpy as np
18 import scipy
---> 19 import scipy.stats
20 import threadpoolctl
21 from .._config import config_context, get_config
~\anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
465 from ._warnings_errors import (ConstantInputWarning, NearConstantInputWarning,
466 DegenerateDataWarning, FitError)
--> 467 from ._stats_py import *
468 from ._variation import variation
469 from .distributions import *
~\anaconda3\lib\site-packages\scipy\stats\_stats_py.py in <module>
35 from numpy import array, asarray, ma
36 from numpy.lib import NumpyVersion
---> 37 from numpy.testing import suppress_warnings
38
39 from scipy.spatial.distance import cdist
ModuleNotFoundError: No module named 'numpy.testing'
'''
This cause due to the numpy version you are using. Therefore you have to downgrade your numpy version to 1.16.4. Use following command.
sudo pip uninstall numpy
pip install numpy==1.16.4
Reference :
https://github.com/DeepLabCut/Docker4DeepLabCut2.0/issues/26
I am trying to apply scipy's Alexander Govern test:
import pandas as pd
import scipy.stats
df1 = pd.read_csv(r'Data1.tsv', sep='\t', encoding='utf-8')
df2 = pd.read_csv(r'Data2.tsv', sep='\t', encoding='utf-8')
from scipy.stats import alexandergovern
alexandergovernTest = alexandergovern(df1.iloc[2:,:135], df2.iloc[2:,:134])
print(alexandergovernTest)
I get the following error:
Traceback (most recent call last):
File "calculate_onewayANOVA.py", line 41, in <module>
from scipy.stats import alexandergovern
ImportError: cannot import name 'alexandergovern'
This error is resolved after upgrading to python3.8 in Ubuntu 20 and installing scipy==1.7.3, as indicated by #Nelewout and #WarrenWeckesser
I am trying to use the zipcodes package but was getting a ses error. Here is a brief snippt of my code.
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
import geopandas as gpd
import requests
import zipfile
import io
import os
import pyproj
from shapely.ops import transform
from functools import partial
import json
from uszipcode import SearchEngine
search = SearchEngine(simple_zipcode=True)
I am getting the following error
Exception ignored in: <function SearchEngine.__del__ at 0x7fcd6087eca0>
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/uszipcode/search.py", line 195, in __del__
if self.ses:
AttributeError: 'SearchEngine' object has no attribute 'ses'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-35-325ac6f8df7d> in <module>
----> 1 search = SearchEngine(simple_zipcode=True)
2 search.ses.scalar(SimpleZipcode)
TypeError: __init__() got an unexpected keyword argument 'simple_zipcode'
Any pointers?
I cannot import any part of scikit-learn library package in Python. I need sklearn.linear_model.LinearRegression but have tried importing various scikit-learn packages each without success. Has anyone had a similar issues with BaseEstimator, or see a solution to loading scikit-learn? Thanks for the help!
System Parameters
Windows 10
Anaconda 1.9.7
scikit-learn 0.21.3
Tried:
Uninstalling and resintalling scikit-learn with conda
Uninstalling and reinstalling Anaconda distribution
loading the specific item that seems to be issue with from sklearn.base import BaseEstimator
running library in Jupyter Notebook, Microsoft VS Code, and Spyder
Code Entered: from sklearn import linear_model
Error Message:
ImportError Traceback (most recent call last)
<ipython-input-1-b94db01ee140> in <module>
----> 1 from sklearn import linear_model
C:\Util\Anaconda3\lib\site-packages\sklearn\__init__.py in <module>
74 else:
75 from . import __check_build
---> 76 from .base import clone
77 from .utils._show_versions import show_versions
78
C:\Util\Anaconda3\lib\site-packages\sklearn\base.py in <module>
14
15 from . import __version__
---> 16 from .utils import _IS_32BIT
17
18 _DEFAULT_TAGS = {
C:\Util\Anaconda3\lib\site-packages\sklearn\utils\__init__.py in <module>
18 from ..exceptions import DataConversionWarning
19 from .deprecation import deprecated
---> 20 from .validation import (as_float_array,
21 assert_all_finite,
22 check_random_state, column_or_1d, check_array,
C:\Util\Anaconda3\lib\site-packages\sklearn\utils\validation.py in <module>
19 from numpy.core.numeric import ComplexWarning
20
---> 21 from .fixes import _object_dtype_isnan
22 from .. import get_config as _get_config
23 from ..exceptions import NonBLASDotWarning
C:\Util\Anaconda3\lib\site-packages\sklearn\utils\fixes.py in <module>
16 import scipy.sparse as sp
17 import scipy
---> 18 from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
19
20
C:\Util\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
114 from .dsolve import *
115 from .interface import *
--> 116 from .eigen import *
117 from .matfuncs import *
118 from ._onenormest import *
C:\Util\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
9 from __future__ import division, print_function, absolute_import
10
---> 11 from .arpack import *
12 from .lobpcg import *
13
C:\Util\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
----> 1 from sklearn.base import BaseEstimator
ImportError: cannot import name 'BaseEstimator' from 'sklearn.base' (C:\Util\Anaconda3\lib\site-packages\sklearn\base.py)
I installed Keras using Pip and when I am trying to import modules from Keras, it gives me an assertion error on utils and init modules.
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-48-eda57b582878> in <module>()
----> 1 from keras.callbacks import LambdaCallback
C:\ProgramData\Anaconda3\lib\site-packages\keras\__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\__init__.py in <module>()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\conv_utils.py in <module>()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
C:\ProgramData\Anaconda3\lib\site-packages\keras\backend\__init__.py in <module>()
34 assert isinstance(_epsilon, float)
35 _backend = _config.get('backend', _BACKEND)
---> 36 assert _backend in {'theano', 'tensorflow', 'cntk'}
37 _image_data_format = _config.get('image_data_format',
38 image_data_format())
AssertionError:
I found a similar question in SOF and checked
python -c "from keras import backend"
in cmd prompt and it gives me the following error.
C:\ProgramData\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\ProgramData\Anaconda3\lib\site-
packages\keras\backend\__init__.py", line 36, in <module>
assert _backend in {'theano', 'tensorflow', 'cntk'}
AssertionError
Keras.json:
{
"image_dim_ordering": "tf",
"backend": "mxnet",
"epsilon": 1e-07,
"floatx": "float32"
}
What should I be changing in these modules to avoid this error?
Thanks in Advance.
Based on your update with the contents of your keras.json file, it appears you have set the backend to "mxnet", but this is not a permitted backend of Keras.
Change this value to one of "tensorflow", "theano", or "cntk" and be sure you have that corresponding package also installed. Save the file and try again.