Skip to content

Commit

Permalink
Convert reading_level into dummy variables
Browse files Browse the repository at this point in the history
  • Loading branch information
zakroum-hicham authored Dec 8, 2024
1 parent 4471862 commit a503e1f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pmml/step1_prepare/step1_2_preprocess_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@

# Extract number from reading level (e.g. 'LEVEL1' --> '1')
storybooks_dataframe['reading_level'] = storybooks_dataframe['reading_level'].str.extract('(\\d+)')

# Convert 'reading_level' into dummy variables
storybooks_dataframe = pandas.concat(
[storybooks_dataframe.drop(columns=['reading_level']), # Drop the original reading_level column
pandas.get_dummies(storybooks_dataframe['reading_level'], prefix='reading_level')], # Add dummy columns
axis=1
)

print(basename(__file__), f'storybooks_dataframe (after converting texts to numbers): \n{storybooks_dataframe}')

# Write the DataFrame to a CSV file
Expand Down

0 comments on commit a503e1f

Please sign in to comment.