Python Transform

Charudatta Mundale Updated by Charudatta Mundale

Tellius provides you to use Python option to: 

  • Cleanse your data of invalid, missing, or inaccurate values
  • Modified your dataset according to your business goals and analysis
  • Enhanced your dataset as needed with data from other datasets

Following are some of the examples to help you get started:

def transform(dataframe):
    # use 8 spaces for indentation
       resultDataframe = dataframe.where(dataframe[‘Payment_Type’] == ‘Visa’)
       return resultDataframe
def transform(dataframe):
    # use 8 spaces for indentation
       resultDataframe = dataframe.where(dataframe[‘workclass’] == ‘Private’)
       return resultDataframe
def transform(dataframe):
    # use 8 spaces for indentation
       resultDataframe = dataframe.withColumn(‘Total’,dataframe.Qty_Sold)
       return resultDataframe
  1. On the dataset Edit page, click the Python icon.
  2. On the Python dialog box, select the required Python framework. Click the Create New button to create a new query.
  3. Enter the name of your Python code.
  4. Enter the Python code that you want to apply and click Run Validate to test the code.

  1. Tellius validates the entered Python code and displays the appropriate message. Click the Save button to save the Python code.
  1. Click the Apply button to apply the Python code to the dataset.

Python Code Validation

  1. Click Data -> Prepare
  2. Click the Edit button. The edit option icons are displayed.
  3. Click the Python icon. The Python code window is displayed.
  4. Select code sample from Code Library or write your code snippet.
  5. Click Edit -> Run Validation.
  6. When the validation is in process, the Running Validation message is displayed.

  1. If the code is correct, the validation result is shown as tick mark, along with a Successfully Validated message displayed at the top.

  1. If the code is incorrect, an error message is displayed along with the incorrect code.

 

How did we do?

SQL Transform

Create Hierarchies

Contact