PromptBase
Close icon
Explore
General
Home
Marketplace
Apps
Create
Login
Sell
πŸ€– GPT

Harmonize Data As A Data Analyst

Harmonize Data As A Data Analyst gpt prompt mini thumbnail
22Eye icon
Views
TestedTick icon
TipsTick icon
πŸ‘€I am a Data Analyst in a global company and want to share with you such useful prompt which I am using almost every day. This prompt will help's you to harmonize data in clear and simply way! 😊
...more
$3.99
Get prompt
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
Updated: Over 1 month ago

Prompt Details

Model
Chat - GPT-3.5 (gpt-3.5-turbo)
Token size
207 ($0.00040 / call)
Example input
Prepare Phyton script for extracting such data: "TREATS", "BISCUITS" , "CHEWS". Don't use operator IN cuz in columns can contain 'float' .
Example output
import pandas as pd # Define the mapping for snack types snack_type_map = { "TREATS": ["FRIANDISE"], "BISCUITS": ["BISCUIT", "BISC"], "CHEWS": ["CHEWS", "CHEW"] } # Read the excel file df = pd.read_excel('data.xlsx') # Define a function to check for snack type def get_snack_type(row): # Check FORM_TYPE column first if isinstance(row['FORM_TYPE'], str): for snack_type, keywords in snack_type_map.items(): for keyword in keywords: if keyword in row['FORM_TYPE']: return snack_type # Check SKU_DESCRIPTION column next if isinstance(row['SKU_DESCRIPTION'], str): for snack_type, keywords in snack_type_map.items(): for keyword in keywords: if keyword in row['SKU_DESCRIPTION']: return snack_type # Return empty string if no match found return '' # Apply the function to create a new column for harmonized snack type df['SNACK_TYPE_HARMONIZED'] = df.apply(lambda row: get_snack_type(row), axis=1) # Save the updated dataframe to a new excel file df.to_excel('data_harmonized.xlsx', index=False)
Browse Marketplace