Forum Discussion
harikm007
09-11-2024Data Warehouse
Hi bminehart ,
To address this, you can use the 'Add Transformation' option within your widget to rename categories.
Here’s a step-by-step approach you can follow:
Use 'Add Transformation' in the Widget:
- Navigate to the widget menu and select 'Add Transformation.'
- You'll need to use a Python script to apply the category name changes. For detailed instructions on how to add transformations, you can refer to the documentation: https://docs.sisense.com/main/SisenseLinux/transforming-query-results-with-python.htm
Script for Transformation:
- In the Jupyter Notebook, under the transformation section, you can use the following script to rename your categories. Make sure to update the mapping variable to reflect your actual old and new category names. Be sure to replace 'Category' with the panel name of the column you added in the widget.
mapping = {
'old_name1': 'new_name 1', 'old_name2': 'new_name 2', 'old_name3': 'new_name 3', 'old_name4': 'new_name 4'
}
df_result = df_input
df_result['Category'] = df_input['Category'].map(lambda x: mapping.get(x, x))
This script maps the old category names to the new ones and ensures that the changes are applied correctly. If a category name does not match any key in the mapping dictionary, it will remain unchanged.
Thanks,
Hari