Skip to Content
Technical Articles
Author's profile photo Pedro Cavaco

Datasphere – A simple python script to clear Null values in Data Flow

In SAP Datasphere if we need to transform null fields coming from a source, we can achieve it using the (python) script operator, for that we can use the following code:

def transform(data):
    
    data['Field1'].fillna('value_to_replace_the_null', inplace=True) 
    data['Field2'].fillna('9999', inplace=True) 
    data['Field3'].fillna('ABC', inplace=True)
    data['Field4'].fillna('XYZ', inplace=True)
    data['FieldN'].fillna('1111', inplace=True)
    
    return data

There are other ways to achieve the same result, but still this is useful if you have any connection limitations and need some ETL while your only option is to use a Data Flow:

Even though we (currently) don’t have a syntax validator for the script operator, it still is a powerful tool.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo praveen kumar
      praveen kumar

      Thanks Pedro Cavaco .

      I have one question :

      I have a requirement to write the pandas script to do forward lookup. Could you please let me know if there exists any pandas DataFrame function to read table data ?

      Author's profile photo Pedro Cavaco
      Pedro Cavaco
      Blog Post Author

      Hello Praveen,

      Check if this article is helpful for your needs.

      Thanks!