I don't think self.df2['Normalized_SAIDI_DPP2'] would be a string as I am guess that you are using pandas dataframe and using .apply with returns a Series or DataFrame so therefore you will need to convert this to string.
I don't think self.df2['Normalized_SAIDI_DPP2'] would be a string as I am guess that you are using pandas dataframe and using .apply with returns a Series or DataFrame so therefore you will need to convert this to string.
Sorry I forgot to mentioned that I also converted the object into string but didn't work. My code was self.df2. Normalized_SAIDI_DPP2'. astype(str).
I don't think self.df2['Normalized_SAIDI_DPP2'] would be a string as I am guess that you are using pandas dataframe and using .apply with returns a Series or DataFrame so therefore you will need to convert this to string.
This is my updated code but still throwing the same error message:
newFeature = fmeobjects.FMEFeature() newFeature.setAttribute('Normalized_SAIDI_DPP2',self.df2['Normalized_SAIDI_DPP2'].astype(str))
I don't think self.df2['Normalized_SAIDI_DPP2'] would be a string as I am guess that you are using pandas dataframe and using .apply with returns a Series or DataFrame so therefore you will need to convert this to string.
I have also tested the following code but ended with same error
newFeature = fmeobjects.FMEFeature() newFeature.setAttribute('Normalized_SAIDI_DPP2',pd.to_numeric(self.df2['Normalized_SAIDI_DPP2']))
Error is :
Python Exception <TypeError>: Could not convert attribute value to a supported attribute type.
Traceback (most recent call last):
File "<string>", line 63, in close
TypeError: Could not convert attribute value to a supported attribute type.
NORMALIZED_DPP2 (PythonFactory): PythonFactory failed to close properly
NORMALIZED_DPP2 (PythonFactory): A fatal error has occurred. Check the logfile above for details
Hi @muhammad_yasir
I'll preface this by saying I'm not familiar with the pandas module at all.
Based on the Pandas documentation, the astype Pandas method only converts Pandas objects (the data values in the column) to the data type specified. You can verify this by using the following Python to check the type:
print(type(self.df2['Normalized_SAIDI_DPP2'].astype(str)))
The results will likely be <class 'pandas.core.series.Series'>. This is not a supported data type as the error returned from the PythonCaller indicates.
Perhaps you can use a for loop to access the data values within the Series object.
Hi @muhammad_yasir
I'll preface this by saying I'm not familiar with the pandas module at all.
Based on the Pandas documentation, the astype Pandas method only converts Pandas objects (the data values in the column) to the data type specified. You can verify this by using the following Python to check the type:
print(type(self.df2['Normalized_SAIDI_DPP2'].astype(str)))
The results will likely be <class 'pandas.core.series.Series'>. This is not a supported data type as the error returned from the PythonCaller indicates.
Perhaps you can use a for loop to access the data values within the Series object.
Yes, you are right, result is <class 'pandas.core.series.Series'> . What does that mean? Could you please also explain what do you mean by use of for loop to access the data values?
Hi @muhammad_yasir
I'll preface this by saying I'm not familiar with the pandas module at all.
Based on the Pandas documentation, the astype Pandas method only converts Pandas objects (the data values in the column) to the data type specified. You can verify this by using the following Python to check the type:
print(type(self.df2['Normalized_SAIDI_DPP2'].astype(str)))
The results will likely be <class 'pandas.core.series.Series'>. This is not a supported data type as the error returned from the PythonCaller indicates.
Perhaps you can use a for loop to access the data values within the Series object.
Do you mean something like this......
for i in self.df2['Normalized_SAIDI_DPP2']:
newFeature = fmeobjects.FMEFeature()
newFeature.setAttribute('Normalized_SAIDI_DPP2',i)
self.pyoutput(newFeature)
pass