October 2019
Beginner to intermediate
674 pages
16h 43m
English
List creation and selection in R is as follows:
>cal_lst<- list(weekdays=1:8, mth='jan') >cal_lst $weekdays [1] 1 2 3 4 5 6 7 8 $mth [1] "jan" >cal_lst[1] $weekdays [1] 1 2 3 4 5 6 7 8 >cal_lst[[1]] [1] 1 2 3 4 5 6 7 8 >cal_lst[2] $mth [1] "jan"
Series creation and selection in pandas is effected as follows:
In [92]: cal_df= pd.Series({'weekdays':range(1,8), 'mth':'jan'})
In [93]: cal_df
Out[93]: mthjan
weekdays [1, 2, 3, 4, 5, 6, 7]
dtype: object
In [97]: cal_df[0]
Out[97]: 'jan'
In [95]: cal_df[1]
Out[95]: [1, 2, 3, 4, 5, 6, 7]
In [96]: cal_df[[1]]
Out[96]: weekdays [1, 2, 3, 4, 5, 6, 7]
dtype: object
Here, we see a difference between an R-list and a pandas series from the perspective of the [] and ...
Read now
Unlock full access