Prompt:
"Generate Python code to create one-hot encodings and frequency encodings for a categorical column."
Output:
df = pd.DataFrame({'category': ['A', 'B', 'A', 'C', 'B']})
one_hot = pd.get_dummies(df['category'], prefix='category')
freq_encoding = df['category'].value_counts().to_dict() df['category_freq'] = df['category'].map(freq_encoding)
one_hot, df
Output Explanation: One-hot-encoded columns and a frequency-encoded column are added to the dataset.