How to solve AttributeError: module 'pandas' has no attribute 'read_xlsx' - python

AttributeError Traceback (most recent call last)
C:\Users\BAMIGB~1\AppData\Local\Temp/ipykernel_15512/4291769960.py in <module>
----> 1 data = pd.read_xlsx ('HRDataset_v14 ().xlsx')
2 data
~\Anaconda3\lib\site-packages\pandas\__init__.py in __getattr__(name)
242 return _SparseArray
243
--> 244 raise AttributeError(f"module 'pandas' has no attribute '{name}'")
245
246
AttributeError: module 'pandas' has no attribute 'read_xlsx'

Instead of this [ data = pd.read_xlsx ('HRDataset_v14 ().xlsx') ] use
data = pd.read_excel ('filename.xlsx')

Related

'Config' object has no attribute 'jax_experimental_name_stack'

Schreenshot of the error message
I'm trying to run Alphafold on Google runtime, and I'm getting this error:
UnfilteredStackTrace Traceback (most recent call last)
<ipython-input-5-ca4ee2dc266d> in <module>
44 processed_feature_dict = model_runner.process_features(np_example, random_seed=0)
---> 45 prediction = model_runner.predict(processed_feature_dict, random_seed=random.randrange(sys.maxsize))
46
UnfilteredStackTrace: AttributeError: 'Config' object has no attribute 'jax_experimental_name_stack'
The stack trace below excludes JAX-internal frames.
The preceding is the original exception that occurred, unmodified.
--------------------
The above exception was the direct cause of the following exception:
AttributeError Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/haiku/_src/module.py in wrapped(self, *args, **kwargs)
406 f = functools.partial(unbound_method, self)
407 f = functools.partial(run_interceptors, f, method_name, self)
--> 408 if jax.config.jax_experimental_name_stack and module_name:
409 local_module_name = module_name.split("/")[-1]
410 f = jax.named_call(f, name=local_module_name)
AttributeError: 'Config' object has no attribute 'jax_experimental_name_stack'
How do I resolve this error? The link for Alphafold is below.
https://colab.research.google.com/github/deepmind/alphafold/blob/main/notebooks/AlphaFold.ipynb

I've tried tf.io.gfile, still results in "AttributeError: module 'tensorflow' has no attribute 'gfile'"

This error is shown when I run
config = config_util.get_configs_from_pipeline_file(CONFIG_PATH):
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-41-efc7822bb0d7> in <module>
----> 1 config = config_util.get_configs_from_pipeline_file(CONFIG_PATH)
~\anaconda3\lib\site-packages\object_detection\utils\config_util.py in get_configs_from_pipeline_file(pipeline_config_path, config_override)
92 """
93 pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
---> 94 with tf.io.gfile.GFile(pipeline_config_path, "r") as f:
95 proto_str = f.read()
96 text_format.Merge(proto_str, pipeline_config)
AttributeError: module 'tensorflow' has no attribute 'gfile'

Python load .features file

I have a dataset (Kvasir data set) with several files that contains the features extraction in the format:
JCD:3.0,3.5,6.0...
Tamura:3.608455882352941,6.681779104634786,632.0,130.0...
ColorLayout:11.0,25.0,9.0,4.0,16.0...
EdgeHistogram:0.0,0.0,4.0,0.0,1.0,1.0,4.0...
AutoColorCorrelogram:13.0,13.0,12.0,12.0,13.0,13.0,12.0...
I'm trying to load all the features files with this code:
dat=sklearn.datasets.load_files("/MTU/Q3/kvasir-dataset-v2-features")
df=pd.DataFrame(data=dat.data,columns=dat.feature_names)
but I get this error:
KeyError Traceback (most recent call last)
C:\Python310\lib\site-packages\sklearn\utils\__init__.py in __getattr__(self, key)
116 try:
--> 117 return self[key]
118 except KeyError:
KeyError: 'feature_names'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_22320/2380416560.py in <module>
----> 1 df=pd.DataFrame(data=dat.data,columns=dat.feature_names)
C:\Python310\lib\site-packages\sklearn\utils\__init__.py in __getattr__(self, key)
117 return self[key]
118 except KeyError:
--> 119 raise AttributeError(key)
120
121 def __setstate__(self, state):
AttributeError: feature_names

pydicom 'Dataset' object has no attribute 'TransferSyntaxUID'

I'm using pydicom 1.0.0a1, downloaded from here, When I run the following code:
ds=pydicom.read_file('./DR/abnormal/abc.dcm',force=True)
ds.pixel_array
this error occurs:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-d4e81d303439> in <module>()
7 ds=pydicom.read_file('./DR/abnormal/abc.dcm',force=True)
8
----> 9 ds.pixel_array
10
/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/dataset.pyc in __getattr__(self, name)
501 if tag is None: # `name` isn't a DICOM element keyword
502 # Try the base class attribute getter (fix for issue 332)
--> 503 return super(Dataset, self).__getattribute__(name)
504 tag = Tag(tag)
505 if tag not in self: # DICOM DataElement not in the Dataset
/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/dataset.pyc in pixel_array(self)
1064 The Pixel Data (7FE0,0010) as a NumPy ndarray.
1065 """
-> 1066 return self._get_pixel_array()
1067
1068 # Format strings spec'd according to python string formatting options
/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/dataset.pyc in _get_pixel_array(self)
1042 elif self._pixel_id != id(self.PixelData):
1043 already_have = False
-> 1044 if not already_have and not self._is_uncompressed_transfer_syntax():
1045 try:
1046 # print("Pixel Data is compressed")
/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/dataset.pyc in _is_uncompressed_transfer_syntax(self)
662 """Return True if the TransferSyntaxUID is a compressed syntax."""
663 # FIXME uses file_meta here, should really only be thus for FileDataset
--> 664 return self.file_meta.TransferSyntaxUID in NotCompressedPixelTransferSyntaxes
665
666 def __ne__(self, other):
/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/dataset.pyc in __getattr__(self, name)
505 if tag not in self: # DICOM DataElement not in the Dataset
506 # Try the base class attribute getter (fix for issue 332)
--> 507 return super(Dataset, self).__getattribute__(name)
508 else:
509 return self[tag].value
AttributeError: 'Dataset' object has no attribute 'TransferSyntaxUID'
I read the google group post , and I changed the filereader.py file to the posted file, and I got this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/__init__.py", line 41, in read_file
from pydicom.dicomio import read_file
File "/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/dicomio.py", line 3, in <module>
from pydicom.filereader import read_file, read_dicomdir
File "/Applications/anaconda/lib/python2.7/site-packages/pydicom-1.0.0a1-py2.7.egg/pydicom/filereader.py", line 35, in <module>
from pydicom.datadict import dictionaryVR
ImportError: cannot import name dictionaryVR
Does anybody know how to solve this problem?
You should set the TransferSyntaxUID after reading the file before trying to get the pixel_array.
import pydicom.uid
ds=pydicom.read_file('./DR/abnormal/abc.dcm',force=True)
ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian # or whatever is the correct transfer syntax for the file
ds.pixel_array
The correction from the post you referenced was done before some changes in the code to harmonize some naming, so the error is thrown because the current master uses dictionary_VR rather than dictionaryVR. Setting the transfer syntax in user code as above avoids that problem.

Sympy, plotting geometric entities yields either ImportError: no module named 'plot' or AttributeError: 'Circle' object has no attribute 'is_3D'

Setup: Using Python 3.4.1 from the Anaconda 2.1.0 64-bit installer for Windows 8.1
Using IPython 2.2.0 console
As usual with the Anaconda installer, I have matplotlib 1.4.0 that comes with it.
And I updated from the default sympy on Anaconda to sympy 0.7.6
Problem: I am trying to plot geometric entities as discussed in the sympy documentation http://docs.sympy.org/latest/modules/plotting.html#plot-geom in at least three ways, all yielding errors.
First try using the 'older' PygletPlot, the module being used in the above reference documentation:
In [1]: from sympy.plotting.pygletplot import PygletPlot as Plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: p = Plot(axes='label_axes=True')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-34da7d3c112c> in <module>()
----> 1 p = Plot(axes='label_axes=True')
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
In [5]: Plot(c1)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-4edba1117b3a> in <module>()
----> 1 Plot(c1)
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
In [6]: p = Plot()
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-f2ff2ed54331> in <module>()
----> 1 p = Plot()
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
Second try using the 'newer' plotting module, which keeps being recommended in answers for most plotting problems with sympy:
In [1]: from sympy.plotting.plot import Plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: p = Plot(c1)
In [5]: p.show()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-709f73884a30> in <module>()
----> 1 p.show()
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in show(self)
182 if hasattr(self, '_backend'):
183 self._backend.close()
--> 184 self._backend = self.backend(self)
185 self._backend.show()
186
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in __new__(cls, parent)
1054 matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
1055 if matplotlib:
-> 1056 return MatplotlibBackend(parent)
1057 else:
1058 return TextBackend(parent)
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in __init__(self, parent)
861 def __init__(self, parent):
862 super(MatplotlibBackend, self).__init__(parent)
--> 863 are_3D = [s.is_3D for s in self.parent._series]
864 self.matplotlib = import_module('matplotlib',
865 __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']},
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in <listcomp>(.0)
861 def __init__(self, parent):
862 super(MatplotlibBackend, self).__init__(parent)
--> 863 are_3D = [s.is_3D for s in self.parent._series]
864 self.matplotlib = import_module('matplotlib',
865 __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']},
AttributeError: 'Circle' object has no attribute 'is_3D'
In [6]: Plot(c1)
Out[6]: <sympy.plotting.plot.Plot at 0x6f74ac8>
Third try using the plot() function which the sympy documentation recommends for interactive work:
In [1]: from sympy import plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: plot(c1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-685b4d90c5ac> in <module>()
----> 1 plot(c1)
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in plot(*args, **kwargs)
1274 series = []
1275 plot_expr = check_arguments(args, 1, 1)
-> 1276 series = [LineOver1DRangeSeries(*arg, **kwargs) for arg in plot_expr]
1277
1278 plots = Plot(*series, **kwargs)
TypeError: 'NoneType' object is not iterable
Thanks for your attention. This is my first time writing a question so I hope I have provided enough information.

Categories