How to do it...

Run the following code, which demonstrates different ways to select data using integer locations:

row_data = df.iloc[2]
col_data = df.iloc[:,1]
single_item = df.iloc[3,1]
df1 = df.iloc[0:2, 1:]

This code results in the following data being stored in each of the corresponding variables:

row_data:

item          Sharpener
inventory            12
unit_price        10.39
Name: 202034, dtype: object

col_data:

100024    24
201024    32
202034    12
101122    42
Name: inventory, dtype: int64

single_item:

42

df1:

             item  unit_price
201024     Eraser        1.29
202034  Sharpener       10.39
101122     Pencil        0.59
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset