17.2: Accessing Individual Elements

The Crystal Ball - Instruction Manual I: Introduction to Data Science · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-SA 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    17.2: Accessing Individual Elements

    I mentioned above the eternal truth that each row of a DataFrame is a Series. Once you grasp this, you’ll realize that you can access an individual “cell” of a DataFrame simply by getting the row you want, and then getting the specific value from that. A two-step process for doing this would be:

    Code \(\PageIndex{1}\) (Python):

    lisas_row = simpsons.loc['Lisa']

    lisas_iq = lisas_row['IQ']

    print(lisas_iq)

    But a shorter, one-stepper just combines these two operations on the same line:

    Code \(\PageIndex{2}\) (Python):

    lisas_iq = simpsons.loc['Lisa']['IQ']

    print(lisas_iq)


    This page titled 17.2: Accessing Individual Elements was last modified on Sun, 18 Sep 2022 02:06:16 GMT and is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Stephen Davies (allthemath.org) via source content that was edited to the style and standards of the LibreTexts platform.