cancel
Showing results for 
Search instead for 
Did you mean: 

Renamed Widget Categories and Exporting to CSV/Excel

bminehart
10 - ETL
10 - ETL

Hello:

I'm doing something similar to what's described in this Community post. It works well when viewing the data in the Widget, however when I export the Widget to a CSV, the original names of the Categories are exported. Is there a way to modify the scripting in such a way that the new category names are kept intact upon export?

Thanks!

1 REPLY 1

harikm007
13 - Data Warehouse
13 - Data 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:

  1. Use 'Add Transformation' in the Widget:

  2. 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))

 

 

harikm007_2-1726051945841.png

 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

https://www.binextlevel.com/