October 2019
Beginner to intermediate
674 pages
16h 43m
English
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
Read now
Unlock full access