I am currently working my way through Mastering Statistics w/ Python, and I often come across the following syntax in the exercises:
In the above example, I am not understanding how we are able to use the column variable as an attribute to the data frame. The only exposure I have had to using attributes in this way is when they are pre-defined in a class; however, it does not seem obvious to me that this would be the case for a given data frame and the variables that make up its columns.
For a concrete example, refer to this exercise here. In it, I am tasked to separate out scores for students who live in urban and rural locations. The scores are kept under the column variable
G3, and the student addresses are stored in the column associated with the
addresses variable. The code below is an example of using column variables as attributes
scores_urban = students.G3[students.address == 'U'] scores_rural = students.G3[students.address == 'R']
Again, I am not understanding what is happening here with the
students.addresses. If someone could please explain, I would greatly appreciate it!
Also, here is the first 5 rows of the data frame for reference: