I have an issue with using the 'loc' function in Python. I would like to extract a specific row from my dataframe 'df', which contains movie titles along with their respective information. The problem is that when I use 'df.loc['movie title']', I receive the following error as if it doesn't exist in the DataFrame, even though it does. Let me show you an example:
df.set_index('title')
And here i receive the correct output
as you can see Toy Story in in DataFrame df but when i try to print all his rae with loc i receive this error: enter image description here
I use pd.loc['Toy Story'] but python say that in my df there isn't any 'Toy story' label Can someone give me an explanation of this?
You need to save the changes to the dataframe. Can you try the following: