Skip to main content
Question

Populating dataframe in Python caller

  • January 30, 2020
  • 3 replies
  • 167 views

Hi there,

 

I am trying to use Python code (which is written externally) in FME by using Python Caller. The purpose of the python program is to create two new attributes after performing manipulation on existing attributes. For this purpose, I create a data frame in the ___init__ of the Python caller, then I use the input function to capture the data that come from different blocks of FME transformation and then do the data manipulation in the close function of Python caller. Now the problem is that this structure slows down the program. I suspect it because of the way I capture the data in the data frame. I have two questions:

1) am I following the right approach to populate the data frame? Is there any better way (quicker) of the populating data frame?

2) Could you please also comment on my general structure of the Python code in Python caller i.e. defining data frame in __init__ function, populating data frame in input function, and final calculation is done in close function?

 

Regards

Yasir

 

 

3 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 30, 2020

This sounds about right to me.

If I need to output every input feature, then what I do is create a self.featureList in the __init__. In the input I append each feature to the list. In the close I do all the processing (with helper functions as necessary).

 


jdh wrote:

This sounds about right to me.

If I need to output every input feature, then what I do is create a self.featureList in the __init__. In the input I append each feature to the list. In the close I do all the processing (with helper functions as necessary).

 

I tried to look at the documentation of featureList, but couldn't find it. Could you please point it out to the right direction?


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 30, 2020
muhammad_yasir wrote:

I tried to look at the documentation of featureList, but couldn't find it. Could you please point it out to the right direction?

my __init__ functions contains the line

self.featureList = []

it's an arbitrary list variable.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings