October 2019
Beginner to intermediate
674 pages
16h 43m
English
We can construct an R DataFrame as follows by calling the data.frame() constructor and then displaying it as follows:
>stocks_table<- data.frame(Symbol=c('GOOG','AMZN','FB','AAPL',
'TWTR','NFLX','LINKD'),
Price=c(518.7,307.82,74.9,109.7,37.1,
334.48,219.9),
MarketCap=c(352.8,142.29,216.98,643.55,23.54,20.15,27.31))
>stocks_table
Symbol PriceMarketCap
1 GOOG 518.70 352.80
2 AMZN 307.82 142.29
3 FB 74.90 216.98
4 AAPL 109.70 643.55
5 TWTR 37.10 23.54
6 NFLX 334.48 20.15
7 LINKD 219.90 27.31
In the following code block, we construct a pandas DataFrame and then display it:
In [29]: stocks_df=pd.DataFrame({'Symbol':['GOOG','AMZN','FB','AAPL', 'TWTR','NFLX','LNKD'], 'Price':[518.7,307.82,74.9,109.7,37.1, 334.48,219.9], 'MarketCap($B)' ...Read now
Unlock full access