Screen Link: https://app.dataquest.io/m/217/guided-project%3A-analyzing-nyc-high-school-data/1/introduction
Dataquest’s solution Code:
Other details: I was searching online in pandas documentation and other sites, couldn’t find anything like this: dataframe.corr() with an immediately afterward, without calling an attribute or method, place the ‘sat_score’ combined column and the list of columns survey_fields , with .plot.bar() at the end.
I’ve tried this same code in some formations, and it just works like this, does anyone know where I can find this pythonic possibility of putting everything in one line? what is the link between them, since there is none of that in the documentation
Everything in Python is actually an object with a type and associated attributes and methods. An attribute is a property of the object that you get or set by giving the object_name + dot + attribute_name, for example
img.shape . A method is a function that the object provides, for example
img.min(). You can combine methods applying them from left to right.
More info on specific functions:
You can use this function like this:
correlations = combined.corr()
correlations = correlations["sat_score"]
or you can simplify this function like this, which will give you totally identical result:
correlations = combined.corr()["sat_score"]
And then you apply
.plot.bar() function to the result:
Hope this helps a little bit to understand how it works. If not, please, feel free to ask more questions!
thanks for untangling the code!