Hello,
This question is primarily caused by this being my first python class implementation in FME.Â
The basic question is? How do I output a new set of features while not outputting the original ones?
Â
Details below:
- I am reading in a set of features to a python caller -class-
- appending them to a dictionary which in turn is converted to a pandas dataframe for analysis on the set of data
- Issue: I have been having trouble outputting the new data in the way I want to:
- What I wanted to do was "drop" the original input fme features and create a new set of features with the new values based on the dataframe. I wanted to do this as I thought it would be quicker than matching the new values to the original input feature
- The issue is shown in the last loop of the code where newFeature = fmeobjects.FMEFeature() is used to create a new feature and assign attribute values, but in the end I am calling self.pyoutput(newFeature) which I believe is referring to the object created from the input features
- How can I output new features without referring to the original data?
Â
- The current output looks like below, I know I could just remove the old unnecessary columns after the python caller runs, but I also know I am doing this wrong and would like to correct my mistake.
Â
import fmeobjects
import pandas as pd
class vAnalys(object):
    def __init__(self):
        #self is convention referring to object created from class (input fme feature)
        #create empty dictionary to store values
        self.data = {"Loc":v],Â
            "Value":d]}Â
       Â
    def input(self,feature):
        #input is called for each fme feature, so instead of looping a list just append the desired values to the dictionary
        self.data 'Loc'].append(feature.getAttribute('Location'))
        self.data"'Value'].append(feature.getAttribute('Measurement'))
       Â
    def close(self):
        #close is not ran for each feature so the processing on the dictionary/dataframe happens here
        #convert the dictionary to pandas dataframe          Â
        df= pd.DataFrame(self.data)
        #complete interpolation
        dfInterp=df.interpolate(method='linear', limit_direction ='both',limit=10)
        #****
        #Complete analysis on dataframe
        #****
        #Iterate through each row of the dataframe
        #creating a new FMEFeature
        #Setting the values to the new values
        for index, row in dfInterp.iterrows():
           #print(index, rowÂ'Loc'], rowi'Value'])
           newFeature = fmeobjects.FMEFeature()
           newFeature.setAttribute('Locat',rowÂ'Loc'])
           newFeature.setAttribute('InterpValue',rowa'Value'])
           #this is referring to the original object created by the class
           self.pyoutput(newFeature)