Skip to main content

Hi there,

 

I am defining a data frame at Python caller on __init__ function like below:

 

class FeatureProcessor(object):

def __init__(self):

df2 = pandas.DataFrame(columns= ='INCIDENT_DATE',INCIDENT_MINS','INCIDENT_VALUE'])

later in the program at input function I am storing feature attribute value in data frame something like that:

def input(self,feature):

self.pyoutput(feature)

df2f'INCIDENT_DATE'] = feature.getAttribute('DATE')

df2f'INCIDENT_MINS'] = feature.getAttribute('MINS')

df2f'INCIDENT_VALUE'] = feature.getAttribute('VALUE_LOST')

 

However, when I ran the Python caller block, it throws an error message that df2 is not defined at the input block. Could anyone point out where am I making the mistake?

 

 

 

 

Hi @muhammad_yasir,

Objects you want to use in multiple methods should be prefixed with 'self.'

ie.

self.df2 = pandas.DataFrame....

.

.

self.df2['INCIDENT_DATE'] =

 


Hum. 

you create a feature output with same value input. 

def input(self,feature):
    self.pyoutput(feature)

  and df2 dataframe can't be set in the constructor __init__ . 

Create a method class to populate data and manipulate it add set your self.df attribute

at the end call a method to generate all your features

def close(self):
    exposeDf(self.df)

in exposeDf method you need create 1 by 1 all element in your df to create all features

 


Reply