Specifying a column name in pandas

In pandas, we subset elements in the usual way with the column name in square brackets:

    In [111]: cal_df['mth']
    Out[111]: 'jan'

One area where R and pandas differ is in the subsetting of nested elements. For example, to obtain day 4 from weekdays, we have to use the [[]] operator in R:

    >cal_lst[[1]][[4]]
    [1] 4
    
    >cal_lst[[c(1,4)]]
    [1] 4 

However, in the case of pandas, we can just use a double []:

    In [132]: cal_df[1][3]
    Out[132]: 4
..................Content has been hidden....................

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