I have 4 classes and 1 interface, when I execute my class Fingerprinter I have this error :
TypeError: unsupported operand type(s) for : 'DatetimeArray' and 'str'
.
The problem is my function def __str__(self)
in my class Fingerprinter
:
def __str__(self):
return self._data_h_df ', ' str(self._modeCB) ', ' str(self._outputMode)
Here is my code :
class OutputMode(object):
def __init__(self,name,startTime,intervalSeconds,timezone):
self.__name = name
self.__startTime = startTime
self.__intervalSeconds = intervalSeconds
self.__timezone = timezone
class Fingerprinter(object):
def __init__(self,data_h_df,outputMode,modeCB=CONST_MODE_CONT):
self._data_h_df = data_h_df
self._modeCB = modeCB
self._outputMode = outputMode
def _generateID(data_h_df):
pass
def run(self):
return self._generateID(data_h_df)
def __str__(self):
return self._data_h_df ', ' str(self._modeCB) ', ' str(self._outputMode)
outputMode = OutputMode('EEA','06:00',8*3600,pytz.timezone('Europe/Paris'))
test = Fingerprinter(data_h_df, outputMode, CONST_MODE_CONT)
print(outputMode)
print(test)
CodePudding user response:
Your problem is self._data_h_df
is probably an array of dates (or at least not a str) and hence cannot be added to a str. Try:
def __str__(self):
return str(self._data_h_df) ', ' str(self._modeCB) ', ' str(self._outputMode)