0
0
Pandasdata~15 mins

str.lower() and str.upper() in Pandas - Mini Project: Build & Apply

Choose your learning style9 modes available
Using str.lower() and str.upper() with pandas
📖 Scenario: You work in a company that collects customer feedback. The feedback data has inconsistent capitalization, making it hard to analyze.You want to standardize the text to either all lowercase or all uppercase to make searching and grouping easier.
🎯 Goal: Standardize the customer feedback text by converting all entries to lowercase and uppercase using pandas string methods.
📋 What You'll Learn
Create a pandas DataFrame with a column named feedback containing exact text entries.
Create a variable to store the column name feedback.
Use str.lower() to convert the feedback text to lowercase.
Use str.upper() to convert the feedback text to uppercase.
Print the resulting lowercase and uppercase DataFrames.
💡 Why This Matters
🌍 Real World
Standardizing text data is important in customer feedback analysis, sentiment analysis, and search functionality to ensure consistent results.
💼 Career
Data analysts and data scientists often clean and preprocess text data using string methods like <code>str.lower()</code> and <code>str.upper()</code> before analysis.
Progress0 / 4 steps
1
Create the feedback DataFrame
Create a pandas DataFrame called df with a column named feedback containing these exact entries: 'Great Service', 'quick response', 'Friendly Staff', 'Will come again'.
Pandas
Need a hint?

Use pd.DataFrame with a dictionary where the key is 'feedback' and the value is the list of strings.

2
Create a variable for the column name
Create a variable called col_name and set it to the string 'feedback'.
Pandas
Need a hint?

Just assign the string 'feedback' to the variable col_name.

3
Convert feedback text to lowercase and uppercase
Create two new variables: lowercase_feedback and uppercase_feedback. Use df[col_name].str.lower() to set lowercase_feedback and df[col_name].str.upper() to set uppercase_feedback.
Pandas
Need a hint?

Use the pandas string methods str.lower() and str.upper() on the column accessed by df[col_name].

4
Print the lowercase and uppercase feedback
Print lowercase_feedback and then print uppercase_feedback.
Pandas
Need a hint?

Use two print() statements, one for each variable.