Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN values in cast.title prevent c.loc[] from being fast after .sort_index() #59

Open
prcantwell opened this issue May 3, 2023 · 0 comments

Comments

@prcantwell
Copy link

Hi Brandon, this is a wonderful tutorial, thanks so much for making it.

The issue I encountered is that running c = cast.set_index(['title']).sort_index() didn't speed up the subsequent search with c.loc['Sleuth']. (This relates to the one-minute segment of the tutorial on YouTube starting at 1:08:54 https://youtu.be/5JnMutdy6Fw?t=4134)

I think the problem is that my version of the cast dataframe has six movies with NaN as the title. When these NaN values get into the index, sorting the index doesn't speed up c.loc['Sleuth']. At least I think this is true based on testing I did with randomly generated dataframes with and without NaN in the index.

I fixed it by making a copy of the cast dataframe without those six movies (the movies with NaN titles), followed by setting and sorting the title index, like this:

c = cast[cast.title.notnull()]
c = c.set_index(['title']).sort_index()

Running c.loc['Sleuth'] on this new NaN-free dataframe is very fast, as expected.

It's possible that I made a mistake when downloading the original data and running the build to make cast. Either way, I thought I should mention this in case someone else has the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant