Can't find doc pythonic example in documentation

Screen Link:

Dataquest’s solution Code: combined.corr()["sat_score"][survey_fields]

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 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

1 Like

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.argmax(axis=0) or 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 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!