Variables And Data Types | Dataquest
In the example of the dataset, the variable is track_name. In an excel file or panda wouldn’t we use track_name? Or does it not matter since we are renaming the variable to app_name? I apologize if this is an unusual question I was not certain if this is common practice and would like to culture myself vs being taken back during workplace activities.
Thank you!
Technically speaking, track_name
is the name of a column and is not a variable like app_name
is. As an example, we can write:
app_name = app_name + " and much more!"
print(app_name)
which is valid python syntax and when printed will display:
Pandora - Music & Radio and much more!
However, this bit of code will throw a NameError
:
track_name = track_name + " testing"
saying that track_name
is not defined (because track_name
is not a variable.)
We are free to label our columns or name our variables as we see fit. However, it is considered best practice to use something descriptive and unambiguous. Personally, I would have labelled the column app_name
instead of track_name
since this dataset contains apps and indeed the documentation found here tells us that track_name
is “App Name.” If this were a dataset containing music titles, I might use track_name
instead.
Be a little careful here…we aren’t renaming anything. We are simply creating variables and storing data in them.
1 Like
Thank you! Gold metal of an explanation. This explanation very detailed and descriptive! I appreciate your efforts and will be best prepared for the future.
1 Like
Thank you, that’s very kind of you. I’m happy to have helped.
Happy coding!