Jupyter Notebook / Python query - When to assign a change to a variable

The below code works on Jupyter, however the second code(my code) doesn’t:
it is finding price of carss

autos = autos.loc[autos[‘price’].between(5000, 50000), : ] # assignment is the key it seems when compared to the second code below
autos.describe ()

my code which doesn’t work and data remains unchanged when describe() is used:

autos.loc[autos[‘price’].between(5000, 50000), : ]

My query is how to know when to assign the result of an operation to a variable ?
I thought my code would work as Jupyter would automatically assign it to autos df, or the pandas would do it with “auto.loc”

My answer here should clarify this - What does the argument "inplace" do in Pandas' DataFrame.dropna()? - #2 by the_doctor

Superb response given to the other question ! I have more questions but i guess i will relish reading the links provided in that and then ask. Thanks !

1 Like