- Hands-On Data Science with Anaconda
- Dr. Yuxing Yan James Yan
- 119字
- 2021-06-25 21:08:50
Slicing and dicing datasets
Our first example is to pick all stocks listed on the NYSE by using an R dataset called marketCap.Rdata, shown in the code here:
> con<-url("http://canisius.edu/~yany/RData/marketCap.RData") > load(con) > head(.marketCap)
The associated output is shown here:
> head(.marketCap) Symbol Name MarketCap Exchange 1 A Agilent Technologies, Inc. $12,852.3 NYSE 2 AA Alcoa Inc. $28,234.5 NYSE 3 AA-P Alcoa Inc. $43.6 AMEX
4 AAC Ableauctions.Com Inc $4.3 AMEX 5 AAI AirTran Holdings, Inc. $156.9 NYSE 6 AAP Advance Auto Parts Inc $3,507.4 NYSE
We have various ways to choose a subset of the R dataset called .marketCap. Note that there is a dot in front of .marketCap:
a<-.marketCap[1] # choose the 1st column b<-.marketCap$SYMBOL # another way to choose the 1st column c<-.marketCap[,1:2] # choose the first two columns d<-subset(.marketCap,.marketCap$EXCHANGE=="NYSE") e<-subset(head(.marketCap)) f<-subset(.marketCap,.marketCap$MARKET>200 & .marketCap$MARKETCAP<=3000)
A Python dataset is downloadable at http://canisius.edu/~yany/python/marketCap.pkl.
推薦閱讀
- Hands-On Internet of Things with MQTT
- 協(xié)作機(jī)器人技術(shù)及應(yīng)用
- 極簡AI入門:一本書讀懂人工智能思維與應(yīng)用
- 工業(yè)機(jī)器人工程應(yīng)用虛擬仿真教程:MotoSim EG-VRC
- STM32G4入門與電機(jī)控制實戰(zhàn):基于X-CUBE-MCSDK的無刷直流電機(jī)與永磁同步電機(jī)控制實現(xiàn)
- Mastering Elastic Stack
- Multimedia Programming with Pure Data
- 大型數(shù)據(jù)庫管理系統(tǒng)技術(shù)、應(yīng)用與實例分析:SQL Server 2005
- 計算機(jī)網(wǎng)絡(luò)技術(shù)基礎(chǔ)
- Blender 3D Printing by Example
- 基于RPA技術(shù)財務(wù)機(jī)器人的應(yīng)用與研究
- JRuby語言實戰(zhàn)技術(shù)
- 運(yùn)動控制系統(tǒng)應(yīng)用及實例解析
- ASP.NET 4.0 MVC敏捷開發(fā)給力起飛
- 亮劍.NET:圖解ASP.NET網(wǎng)站開發(fā)實戰(zhàn)