...

/

Solution Explanations: Text Feature Engineering

Solution Explanations: Text Feature Engineering

Review solution explanations for the code challenges on text feature engineering.

Solution 1: Feature construction

Here’s the solution:

Press + to interact
main.py
feedback.csv
import pandas as pd
feedback_df = pd.read_csv('feedback.csv')
feedback_df['feedback_length_chars'] = feedback_df['feedback'].apply(lambda x: len(x))
feedback_df['feedback_length_words'] = feedback_df['feedback'].apply(lambda x: len(x.split()))
print(feedback_df['feedback_length_chars'])
print(feedback_df['feedback_length_words'])

Let’s go through the solution explanation:

  • Line 4: We create a new column named feedback_length_chars using the apply() function on the feedback column. For each text in the ...

Access this course and 1400+ top-rated courses and projects.