aws-samples / aws-samples/amazon-personalize-samples

05_Interacting_with_Campaigns_and_Filters.ipynb - loading in .csv file with title cast as str and then reference as int

Open
#154 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
602
Forks
338
PR merge metrics
No merged PRs in 30d

Description

noticed I was getting key errors when running through the notebook:
[05_Interacting_with_Campaigns_and_Filters.ipynb](https://github.com/aws-samples/amazon-personalize-samples/blob/master/next_steps/workshops/POC_in_a_box/05_Interacting_with_Campaigns_and_Filters.ipynb)

when reading in the dataframe from the .csv, we cast title( a unique integer value) as 'str' - but all the following code references it as being cast as 'int'.
Easy fix is to change the following:

# Create a dataframe for the items by reading in the correct source CSV
items_df = pd.read_csv(dataset_dir + '/movies.csv', sep=',', usecols=[0,1], encoding='latin-1', dtype={'movieId': "object", 'title': "**str**"},index_col=0)
to
# Create a dataframe for the items by reading in the correct source CSV
items_df = pd.read_csv(dataset_dir + '/movies.csv', sep=',', usecols=[0,1], encoding='latin-1', dtype={'movieId': "object", 'title': "**int**"},index_col=0)

Contributor guide

Open the contributing guide

Research direction

Open next_steps/workshops/POC_in_a_box/05_Interacting_with_Campaigns_and_Filters.ipynb and inspect the items dataframe loading cell. Compare the declared title dtype with the later integer references, then run the notebook from that step to confirm the key errors are gone and the item identifiers remain consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, pandas, python
Domain
data, machine-learning
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.