Give an example of how to standardize string values in a column of a Data Frame.
- User
Give an example of how to standardize string values in a column of a Data Frame.
Assistant
Here's how to standardize string values in a DataFrame column:
pythonimport pandas as pd # Sample DataFrame df = pd.DataFrame({ 'customer_status': ['ACTIVE', 'active', 'Active', 'INACTIVE', 'inactive', ' active '] }) # Standardize the string values (lowercase and strip whitespace) df['customer_status'] = df['customer_status'].str.lower().str.strip() print(df)Would you like me to explain how this code works or show additional standardization techniques?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.