October 2019
Beginner to intermediate
674 pages
16h 43m
English
R lists can be created explicitly as a list declaration, shown as follows:
>h_lst<- list(23,'donkey',5.6,1+4i,TRUE) >h_lst [[1]] [1] 23 [[2]] [1] "donkey" [[3]] [1] 5.6 [[4]] [1] 1+4i [[5]] [1] TRUE >typeof(h_lst) [1] "list"
The following code block includes its series equivalent in pandas, with the creation of a list followed by the creation of a series therefrom:
In [8]: h_list=[23, 'donkey', 5.6,1+4j, True]
In [9]: import pandas as pd
h_ser=pd.Series(h_list)
In [10]: h_ser
Out[10]: 0 23
1 donkey
2 5.6
3 (1+4j)
4 True
dtype: object
Array indexing starts at 0 in pandas, unlike R, where it starts at 1. The following is an example:
In [11]: type(h_ser)
Out[11]: pandas.core.series.Series
Read now
Unlock full access