Running Jupyter notebook example for Facets Overview fails
I am receiving the following error message:
TypeError: 24720 has type <class 'numpy.int64'>, but expected one of: (<class 'float'>, <class 'int'>, <class 'int'>)
Full error log:
TypeError Traceback (most recent call last) c:\users\shahar karny\appdata\local\programs\python\python35\lib\site-packages\google\protobuf\internal\python_message.py in init(self, **kwargs) 460 try: --> 461 setattr(self, field_name, field_value) 462 except TypeError:
c:\users\shahar karny\appdata\local\programs\python\python35\lib\site-packages\google\protobuf\internal\python_message.py in field_setter(self, new_value) 595 # (0, 0.0, enum 0, and False). --> 596 new_value = type_checker.CheckValue(new_value) 597 if clear_when_set_to_default and not new_value:
c:\users\shahar karny\appdata\local\programs\python\python35\lib\site-packages\google\protobuf\internal\type_checkers.py in CheckValue(self, proposed_value) 108 (proposed_value, type(proposed_value), self._acceptable_types)) --> 109 raise TypeError(message) 110 return proposed_value
TypeError: 24720 has type <class 'numpy.int64'>, but expected one of: (<class 'float'>, <class 'int'>, <class 'int'>)
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
c:\GitProjects\facets\facets_overview\python\base_generic_feature_statistics_generator.py in ProtoFromDataFrames(self, dataframes) 53 'name': dataframe['name'] 54 }) ---> 55 return self.GetDatasetsProto(datasets) 56 57 def DtypeToType(self, dtype):
c:\GitProjects\facets\facets_overview\python\base_generic_feature_statistics_generator.py in GetDatasetsProto(self, datasets, features) 256 high_rank=val_index, 257 sample_count=val[0], --> 258 label=printable_val) 259 if val_index < 2: 260 featstats.top_values.add(
c:\users\shahar karny\appdata\local\programs\python\python35\lib\site-packages\google\protobuf\internal\containers.py in add(self, **kwargs) 367 arguments may be used to initialize the element. 368 """ --> 369 new_element = self._message_descriptor._concrete_class(**kwargs) 370 new_element._SetListener(self._message_listener) 371 self._values.append(new_element)
c:\users\shahar karny\appdata\local\programs\python\python35\lib\site-packages\google\protobuf\internal\python_message.py in init(self, **kwargs) 461 setattr(self, field_name, field_value) 462 except TypeError: --> 463 _ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name) 464 465 init.module = None
c:\users\shahar karny\appdata\local\programs\python\python35\lib\site-packages\google\protobuf\internal\python_message.py in _ReraiseTypeErrorWithFieldName(message_name, field_name) 384 385 # re-raise possibly-amended exception with original traceback: --> 386 raise type(exc)(exc, sys.exc_info()[2]) 387 388
TypeError: (TypeError("24720 has type <class 'numpy.int64'>, but expected one of: (<class 'float'>, <class 'int'>, <class 'int'>) for field Bucket.sample_count",), <traceback object at 0x0000027750F9A708>)
I wonder if this is some sort of python and/or numpy version issue.
Try changing base_generic_feature_statistics_generator.py:257 to be "sample_count=np.asscalar(val[0])," and see if that makes a difference for you. That will force the numpy scalar to be cast to a native python type I believe. Let me know if that gets you past that line.
Thanks James. I used int() casting @line 257 and in several other code sections and it passed ! If you like, I can PR my changes.
Regarding the versions I use: pip freeze appdirs==1.4.3 numpy==1.13.0+mkl opencv-python==3.2.0 packaging==16.8 Pillow==3.0.0 protobuf==3.3.0 pyparsing==2.2.0 scipy==0.19.0 six==1.10.0 tensorflow==1.1.0 Werkzeug==0.12.2