Skip to content

Instantly share code, notes, and snippets.

@chrisdubois
Created October 22, 2014 23:29
Show Gist options
  • Save chrisdubois/71e48912cbffb03b9182 to your computer and use it in GitHub Desktop.
Save chrisdubois/71e48912cbffb03b9182 to your computer and use it in GitHub Desktop.
Comparing dplyr, pandas, and GraphLab Create syntax for analyzing airlines data
{
"metadata": {
"name": "",
"signature": "sha256:02c98fadc77e55f0faa88d532e41a3db7cf49c59dd9a18e0c952b36bd96767c4"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook contains a few quick examples using airline data borrowed from dplyr\u2019s [introductory vignette](http://cran.r-project.org/web/packages/dplyr/vignettes/introduction.html). The [original notebook](http://nbviewer.ipython.org/gist/TomAugspurger/6e052140eaa5fdb6e8c0) was used to compare the syntax between dplyr and pandas. Here we simply add the corresponding SFrame commands to illustrate the similarities as well as provide a quick translation for those getting started.\n",
"\n",
"Each code block shows the syntax for dplyr, pandas, and [GraphLab Create](http://graphlab.com/products/create/overview.html)."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"## In R:\n",
"# library(\"nycflights13\")\n",
"# write.csv(flights, \"flights.csv\")"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import graphlab as gl"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"flights = gl.SFrame.read_csv('flights.csv')"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# plyr: dim(flights) <--- R code using dplyr\n",
"# pandas: flights.shape <--- Python code using pandas\n",
"flights.shape #<--- Python code using GraphLab Create"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": [
"(336776, 17)"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: head(flights)\n",
"# pandas: flights.head()\n",
"flights.head()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tailnum</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">517</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">830</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N14228</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1545</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">533</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">850</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N24211</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1714</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">542</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">923</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N619AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1141</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MIA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">544</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1004</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N804JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">725</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BQN</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">812</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N668DN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">461</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">740</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N39463</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1696</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">555</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">913</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N516JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">507</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">FLL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">709</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EV</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N829AS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5708</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">838</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N593JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">79</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MCO</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">558</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">753</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N3ALAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">301</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1400</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1416</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">160</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1089</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">42</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">183</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1576</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">116</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">762</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">150</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">719</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">158</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1065</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">55</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">53</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">229</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">140</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">944</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">138</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">733</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">58</td>\n",
" </tr>\n",
"</table>\n",
"[10 rows x 17 columns]<br/>\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttailnum\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\n",
"Rows: 10\n",
"\n",
"Data:\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 1 | 2013 | 1 | 1 | 517 | 2 | 830 | 11 | UA |\n",
"| 2 | 2013 | 1 | 1 | 533 | 4 | 850 | 20 | UA |\n",
"| 3 | 2013 | 1 | 1 | 542 | 2 | 923 | 33 | AA |\n",
"| 4 | 2013 | 1 | 1 | 544 | -1 | 1004 | -18 | B6 |\n",
"| 5 | 2013 | 1 | 1 | 554 | -6 | 812 | -25 | DL |\n",
"| 6 | 2013 | 1 | 1 | 554 | -4 | 740 | 12 | UA |\n",
"| 7 | 2013 | 1 | 1 | 555 | -5 | 913 | 19 | B6 |\n",
"| 8 | 2013 | 1 | 1 | 557 | -3 | 709 | -14 | EV |\n",
"| 9 | 2013 | 1 | 1 | 557 | -3 | 838 | -8 | B6 |\n",
"| 10 | 2013 | 1 | 1 | 558 | -2 | 753 | 8 | AA |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| tailnum | flight | origin | dest | air_time | distance | hour | minute |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| N14228 | 1545 | EWR | IAH | 227 | 1400 | 5 | 17 |\n",
"| N24211 | 1714 | LGA | IAH | 227 | 1416 | 5 | 33 |\n",
"| N619AA | 1141 | JFK | MIA | 160 | 1089 | 5 | 42 |\n",
"| N804JB | 725 | JFK | BQN | 183 | 1576 | 5 | 44 |\n",
"| N668DN | 461 | LGA | ATL | 116 | 762 | 5 | 54 |\n",
"| N39463 | 1696 | EWR | ORD | 150 | 719 | 5 | 54 |\n",
"| N516JB | 507 | EWR | FLL | 158 | 1065 | 5 | 55 |\n",
"| N829AS | 5708 | LGA | IAD | 53 | 229 | 5 | 57 |\n",
"| N593JB | 79 | JFK | MCO | 140 | 944 | 5 | 57 |\n",
"| N3ALAA | 301 | LGA | ORD | 138 | 733 | 5 | 58 |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"[10 rows x 17 columns]"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: flights[flights$month == 1 & flights$day == 1, ]\n",
"# pandas: flights[(flights.month == 1) & (flights.day == 1)]\n",
"flights[flights['month'] == 1 and flights['day'] == 1]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tailnum</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">517</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">830</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N14228</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1545</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">533</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">850</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N24211</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1714</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">542</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">923</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N619AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1141</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MIA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">544</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1004</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N804JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">725</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BQN</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">812</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N668DN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">461</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">740</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N39463</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1696</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">555</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">913</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N516JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">507</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">FLL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">709</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EV</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N829AS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5708</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">838</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N593JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">79</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MCO</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">558</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">753</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N3ALAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">301</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1400</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1416</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">160</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1089</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">42</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">183</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1576</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">116</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">762</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">150</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">719</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">158</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1065</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">55</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">53</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">229</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">140</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">944</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">138</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">733</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">58</td>\n",
" </tr>\n",
"</table>\n",
"[? rows x 17 columns]<br/>Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.<br/>You can use len(sf) to force materialization.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 6,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttailnum\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\n",
"Rows: Unknown\n",
"\n",
"Data:\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 1 | 2013 | 1 | 1 | 517 | 2 | 830 | 11 | UA |\n",
"| 2 | 2013 | 1 | 1 | 533 | 4 | 850 | 20 | UA |\n",
"| 3 | 2013 | 1 | 1 | 542 | 2 | 923 | 33 | AA |\n",
"| 4 | 2013 | 1 | 1 | 544 | -1 | 1004 | -18 | B6 |\n",
"| 5 | 2013 | 1 | 1 | 554 | -6 | 812 | -25 | DL |\n",
"| 6 | 2013 | 1 | 1 | 554 | -4 | 740 | 12 | UA |\n",
"| 7 | 2013 | 1 | 1 | 555 | -5 | 913 | 19 | B6 |\n",
"| 8 | 2013 | 1 | 1 | 557 | -3 | 709 | -14 | EV |\n",
"| 9 | 2013 | 1 | 1 | 557 | -3 | 838 | -8 | B6 |\n",
"| 10 | 2013 | 1 | 1 | 558 | -2 | 753 | 8 | AA |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| tailnum | flight | origin | dest | air_time | distance | hour | minute |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| N14228 | 1545 | EWR | IAH | 227 | 1400 | 5 | 17 |\n",
"| N24211 | 1714 | LGA | IAH | 227 | 1416 | 5 | 33 |\n",
"| N619AA | 1141 | JFK | MIA | 160 | 1089 | 5 | 42 |\n",
"| N804JB | 725 | JFK | BQN | 183 | 1576 | 5 | 44 |\n",
"| N668DN | 461 | LGA | ATL | 116 | 762 | 5 | 54 |\n",
"| N39463 | 1696 | EWR | ORD | 150 | 719 | 5 | 54 |\n",
"| N516JB | 507 | EWR | FLL | 158 | 1065 | 5 | 55 |\n",
"| N829AS | 5708 | LGA | IAD | 53 | 229 | 5 | 57 |\n",
"| N593JB | 79 | JFK | MCO | 140 | 944 | 5 | 57 |\n",
"| N3ALAA | 301 | LGA | ORD | 138 | 733 | 5 | 58 |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"[? rows x 17 columns]\n",
"Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.\n",
"You can use len(sf) to force materialization."
]
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: slice(flights, 1:10)\n",
"# pandas: flights.iloc[:9]\n",
"flights[:9]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tailnum</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">517</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">830</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N14228</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1545</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">533</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">850</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N24211</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1714</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">542</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">923</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N619AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1141</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MIA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">544</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1004</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N804JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">725</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BQN</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">812</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N668DN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">461</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">740</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N39463</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1696</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">555</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">913</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N516JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">507</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">FLL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">709</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EV</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N829AS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5708</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">838</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N593JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">79</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MCO</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1400</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1416</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">160</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1089</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">42</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">183</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1576</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">116</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">762</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">150</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">719</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">158</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1065</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">55</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">53</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">229</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">140</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">944</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
"</table>\n",
"[9 rows x 17 columns]<br/>\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 7,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttailnum\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\n",
"Rows: 9\n",
"\n",
"Data:\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 1 | 2013 | 1 | 1 | 517 | 2 | 830 | 11 | UA |\n",
"| 2 | 2013 | 1 | 1 | 533 | 4 | 850 | 20 | UA |\n",
"| 3 | 2013 | 1 | 1 | 542 | 2 | 923 | 33 | AA |\n",
"| 4 | 2013 | 1 | 1 | 544 | -1 | 1004 | -18 | B6 |\n",
"| 5 | 2013 | 1 | 1 | 554 | -6 | 812 | -25 | DL |\n",
"| 6 | 2013 | 1 | 1 | 554 | -4 | 740 | 12 | UA |\n",
"| 7 | 2013 | 1 | 1 | 555 | -5 | 913 | 19 | B6 |\n",
"| 8 | 2013 | 1 | 1 | 557 | -3 | 709 | -14 | EV |\n",
"| 9 | 2013 | 1 | 1 | 557 | -3 | 838 | -8 | B6 |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| tailnum | flight | origin | dest | air_time | distance | hour | minute |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| N14228 | 1545 | EWR | IAH | 227 | 1400 | 5 | 17 |\n",
"| N24211 | 1714 | LGA | IAH | 227 | 1416 | 5 | 33 |\n",
"| N619AA | 1141 | JFK | MIA | 160 | 1089 | 5 | 42 |\n",
"| N804JB | 725 | JFK | BQN | 183 | 1576 | 5 | 44 |\n",
"| N668DN | 461 | LGA | ATL | 116 | 762 | 5 | 54 |\n",
"| N39463 | 1696 | EWR | ORD | 150 | 719 | 5 | 54 |\n",
"| N516JB | 507 | EWR | FLL | 158 | 1065 | 5 | 55 |\n",
"| N829AS | 5708 | LGA | IAD | 53 | 229 | 5 | 57 |\n",
"| N593JB | 79 | JFK | MCO | 140 | 944 | 5 | 57 |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"[9 rows x 17 columns]"
]
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: arrange(flights, year, month, day) \n",
"# pandas: flights.sort(['year', 'month', 'day'])\n",
"flights.sort(['year', 'month', 'day'])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tailnum</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">567</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1653</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2005</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-13</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N980DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1807</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">FLL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1634</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1913</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">21</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N27213</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">69</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DEN</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">555</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1635</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1830</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N16701</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">162</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">CLE</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">556</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1636</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1747</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N190JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1176</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BOS</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1637</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">52</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1858</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">39</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9E</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N604LR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3321</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MSP</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">558</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1639</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">82</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1815</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">96</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EV</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N16561</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4580</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MKE</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">559</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1640</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">0</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1859</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N723MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4540</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DTW</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">560</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1641</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1746</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-34</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N3BYAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1790</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BOS</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">561</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1642</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">32</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1944</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N17229</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1587</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">RSW</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">562</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1645</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1832</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EV</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N13538</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4336</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">GSO</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">158</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1076</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">53</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">247</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1605</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">34</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">84</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">404</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">35</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">42</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">200</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">36</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">173</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1029</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">37</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">140</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">725</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">39</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">106</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">502</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">40</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">41</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">187</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">41</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">161</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1068</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">42</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">89</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">445</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">45</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[336776 rows x 17 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 8,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttailnum\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\n",
"Rows: 336776\n",
"\n",
"Data:\n",
"+-----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+-----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 567 | 2013 | 1 | 1 | 1653 | -7 | 2005 | -13 | DL |\n",
"| 554 | 2013 | 1 | 1 | 1634 | 8 | 1913 | 21 | UA |\n",
"| 555 | 2013 | 1 | 1 | 1635 | 5 | 1830 | 20 | UA |\n",
"| 556 | 2013 | 1 | 1 | 1636 | -3 | 1747 | -8 | B6 |\n",
"| 557 | 2013 | 1 | 1 | 1637 | 52 | 1858 | 39 | 9E |\n",
"| 558 | 2013 | 1 | 1 | 1639 | 82 | 1815 | 96 | EV |\n",
"| 559 | 2013 | 1 | 1 | 1640 | 0 | 1859 | 9 | MQ |\n",
"| 560 | 2013 | 1 | 1 | 1641 | -9 | 1746 | -34 | AA |\n",
"| 561 | 2013 | 1 | 1 | 1642 | 32 | 1944 | 25 | UA |\n",
"| 562 | 2013 | 1 | 1 | 1645 | 6 | 1832 | 16 | EV |\n",
"+-----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| tailnum | flight | origin | dest | air_time | distance | hour | minute |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| N980DL | 1807 | LGA | FLL | 158 | 1076 | 16 | 53 |\n",
"| N27213 | 69 | EWR | DEN | 247 | 1605 | 16 | 34 |\n",
"| N16701 | 162 | EWR | CLE | 84 | 404 | 16 | 35 |\n",
"| N190JB | 1176 | EWR | BOS | 42 | 200 | 16 | 36 |\n",
"| N604LR | 3321 | JFK | MSP | 173 | 1029 | 16 | 37 |\n",
"| N16561 | 4580 | EWR | MKE | 140 | 725 | 16 | 39 |\n",
"| N723MQ | 4540 | LGA | DTW | 106 | 502 | 16 | 40 |\n",
"| N3BYAA | 1790 | JFK | BOS | 41 | 187 | 16 | 41 |\n",
"| N17229 | 1587 | EWR | RSW | 161 | 1068 | 16 | 42 |\n",
"| N13538 | 4336 | EWR | GSO | 89 | 445 | 16 | 45 |\n",
"| ... | ... | ... | ... | ... | ... | ... | ... |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"[336776 rows x 17 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: arrange(flights, desc(arr_delay))\n",
"# pandas: flights.sort('arr_delay', ascending=False)\n",
"flights.sort('arr_delay', ascending=False)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tailnum</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7073</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">641</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1301</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1242</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1272</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">HA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N384HA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">51</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">HNL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">235779</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">15</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1432</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1137</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1607</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1127</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N504MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3535</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">CMH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8240</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1121</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1126</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1239</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1109</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N517MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3695</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">327044</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1139</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1014</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1457</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1007</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N338AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">177</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">SFO</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">270377</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">22</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">845</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1005</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1044</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">989</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N665MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3075</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">CVG</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">173993</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1100</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">960</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1342</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">931</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N959DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2391</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">TPA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">151975</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2321</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">911</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">135</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">915</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N927DA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2119</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MSP</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">270988</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">22</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2257</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">898</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">121</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">895</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N6716C</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2047</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">87239</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">756</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">896</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1058</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">878</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N5DMAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">172</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MIA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">195712</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1133</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">878</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1250</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">875</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N523MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3744</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">640</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4983</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">41</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">74</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">483</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">32</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">111</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">719</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">21</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">354</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2586</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">39</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">96</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">589</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">45</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">139</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1005</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">0</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">167</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1020</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">23</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">21</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">109</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">762</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">22</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">149</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1085</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">56</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">112</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">719</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[336776 rows x 17 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 9,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttailnum\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\n",
"Rows: 336776\n",
"\n",
"Data:\n",
"+--------+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+--------+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 7073 | 2013 | 1 | 9 | 641 | 1301 | 1242 | 1272 | HA |\n",
"| 235779 | 2013 | 6 | 15 | 1432 | 1137 | 1607 | 1127 | MQ |\n",
"| 8240 | 2013 | 1 | 10 | 1121 | 1126 | 1239 | 1109 | MQ |\n",
"| 327044 | 2013 | 9 | 20 | 1139 | 1014 | 1457 | 1007 | AA |\n",
"| 270377 | 2013 | 7 | 22 | 845 | 1005 | 1044 | 989 | MQ |\n",
"| 173993 | 2013 | 4 | 10 | 1100 | 960 | 1342 | 931 | DL |\n",
"| 151975 | 2013 | 3 | 17 | 2321 | 911 | 135 | 915 | DL |\n",
"| 270988 | 2013 | 7 | 22 | 2257 | 898 | 121 | 895 | DL |\n",
"| 87239 | 2013 | 12 | 5 | 756 | 896 | 1058 | 878 | AA |\n",
"| 195712 | 2013 | 5 | 3 | 1133 | 878 | 1250 | 875 | MQ |\n",
"+--------+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| tailnum | flight | origin | dest | air_time | distance | hour | minute |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"| N384HA | 51 | JFK | HNL | 640 | 4983 | 6 | 41 |\n",
"| N504MQ | 3535 | JFK | CMH | 74 | 483 | 14 | 32 |\n",
"| N517MQ | 3695 | EWR | ORD | 111 | 719 | 11 | 21 |\n",
"| N338AA | 177 | JFK | SFO | 354 | 2586 | 11 | 39 |\n",
"| N665MQ | 3075 | JFK | CVG | 96 | 589 | 8 | 45 |\n",
"| N959DL | 2391 | JFK | TPA | 139 | 1005 | 11 | 0 |\n",
"| N927DA | 2119 | LGA | MSP | 167 | 1020 | 23 | 21 |\n",
"| N6716C | 2047 | LGA | ATL | 109 | 762 | 22 | 57 |\n",
"| N5DMAA | 172 | EWR | MIA | 149 | 1085 | 7 | 56 |\n",
"| N523MQ | 3744 | EWR | ORD | 112 | 719 | 11 | 33 |\n",
"| ... | ... | ... | ... | ... | ... | ... | ... |\n",
"+---------+--------+--------+------+----------+----------+------+--------+\n",
"[336776 rows x 17 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: select(flights, year, month, day) \n",
"# pandas: flights[['year', 'month', 'day']]\n",
"flights[['year', 'month', 'day']]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[336776 rows x 3 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 10,
"text": [
"Columns:\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\n",
"Rows: 336776\n",
"\n",
"Data:\n",
"+------+-------+-----+\n",
"| year | month | day |\n",
"+------+-------+-----+\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| 2013 | 1 | 1 |\n",
"| ... | ... | ... |\n",
"+------+-------+-----+\n",
"[336776 rows x 3 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 10
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: select(flights, tail_num = tailnum)\n",
"# pandas: flights.rename(columns={'tailnum': 'tail_num'})['tail_num']\n",
"flights.rename({'tailnum': 'tail_num'})\n",
"flights['tail_num']"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 11,
"text": [
"dtype: str\n",
"Rows: 336776\n",
"['N14228', 'N24211', 'N619AA', 'N804JB', 'N668DN', 'N39463', 'N516JB', 'N829AS', 'N593JB', 'N3ALAA', 'N793JB', 'N657JB', 'N29129', 'N53441', 'N3DUAA', 'N708JB', 'N76515', 'N595JB', 'N542MQ', 'N644JB', 'N971DL', 'N730MQ', 'N633AA', 'N3739P', 'N53442', 'N9EAMQ', 'N532UA', 'N635JB', 'N794JB', 'N326NB', 'N807AW', 'N3EMAA', 'N459UA', 'N11107', 'N518MQ', 'N535UW', 'N3BAAA', 'N33289', 'N3CYAA', 'N273WN', 'N426US', 'N13553', 'N3GKAA', 'N709JB', 'N805JB', 'N497UA', 'N178US', 'N75435', 'N796JB', 'N569UA', 'N38727', 'N558JB', 'N178JB', 'N327NW', 'N3763D', 'N705TW', 'N997DL', 'N4WNAA', 'N5FMAA', 'N722MQ', 'N24212', 'N318NB', 'N6703D', 'N627VA', 'N3EKAA', 'N646JB', 'N998DL', 'N838UA', 'N77296', 'N779JB', 'N26226', 'N651JB', 'N3ETAA', 'N841UA', 'N978AT', 'N562JB', 'N514UA', 'N541AA', 'N594AS', 'N4WRAA', 'N37462', 'N488UA', 'N635VA', 'N304JB', 'N563JB', 'N37456', 'N552JB', 'N625JB', 'N4WPAA', 'N37408', 'N633JB', 'N338AA', 'N624JB', 'N3760C', 'N336AA', 'N24224', 'N508MQ', 'N325US', 'N511UA', 'N543UW', ... ]"
]
}
],
"prompt_number": 11
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(Currently SFrame.rename does an inplace modification.)"
]
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Extract distinct (unique) rows"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: distinct(select(flights, tailnum))\n",
"# pandas: flights.tailnum.unique()\n",
"flights['tail_num'].unique()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 12,
"text": [
"dtype: str\n",
"Rows: 4044\n",
"['N3EHAA', 'N388DA', 'N938WN', 'N622SW', 'N353NW', 'N928DN', 'N588JB', 'N959UW', 'N701GS', 'N7BGAA', 'N932DN', 'N585UA', 'N826MQ', 'N544AA', 'N385DN', 'N735SA', 'N627SW', 'N37253', 'N766US', 'N37456', 'N7746C', 'N724EV', 'N76505', 'N360NW', 'N767NC', 'N380SW', 'N520UW', 'N73291', 'N112US', 'N850UA', 'N669AW', 'N900PC', 'N341NW', 'N313US', 'N34131', 'N465WN', 'N755EV', 'N900WN', 'N990DL', 'N204WN', 'N513UA', 'N676AW', 'N958AT', 'N907MQ', 'N640MQ', 'N629JB', 'N3GTAA', 'N901XJ', 'N688DL', 'N730US', 'N371NW', 'N837UA', 'N641MQ', 'N3BLAA', 'N3JBAA', 'N790SK', 'N565AS', 'N930AT', 'N375DA', 'N959DL', 'N608JB', 'N5FMAA', 'N13718', 'N634VA', 'N954DL', 'N15910', 'N526UA', 'N3742C', 'N8307K', 'N481WN', 'N8718E', 'N551UA', 'N914DL', 'N703TW', 'N903DA', 'N37465', 'N914WN', 'N779SW', 'N637JB', 'N12145', 'N344AT', 'N76502', 'N961UW', 'N527VA', 'N68802', 'N329JB', 'N507JB', 'N983DL', 'N958DL', 'N797SK', 'N607AT', 'N3CLAA', 'N694SW', 'N960AT', 'N406UA', 'N368AA', 'N912FJ', 'N178DZ', 'N698MQ', 'N522LR', ... ]"
]
}
],
"prompt_number": 12
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that the returned object is an SArray."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: distinct(select(flights, origin, dest))\n",
"# pandas: flights[['origin', 'dest']].drop_duplicates()\n",
"flights[['origin', 'dest']].unique()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">PSE</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IND</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">SLC</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">RIC</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">PDX</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">SRQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">CLE</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">PIT</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MCO</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[224 rows x 2 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 13,
"text": [
"Columns:\n",
"\tdest\tstr\n",
"\torigin\tstr\n",
"\n",
"Rows: 224\n",
"\n",
"Data:\n",
"+------+--------+\n",
"| dest | origin |\n",
"+------+--------+\n",
"| PSE | JFK |\n",
"| IND | JFK |\n",
"| SLC | JFK |\n",
"| IAH | JFK |\n",
"| RIC | JFK |\n",
"| PDX | JFK |\n",
"| SRQ | JFK |\n",
"| CLE | JFK |\n",
"| PIT | JFK |\n",
"| MCO | JFK |\n",
"| ... | ... |\n",
"+------+--------+\n",
"[224 rows x 2 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#dplyr: mutate(flights,\n",
"# gain = arr_delay - dep_delay,\n",
"# speed = distance / air_time * 60)\n",
"# pandas: \n",
"# flights['gain'] = flights.arr_delay - flights.dep_delay\n",
"# flights['speed'] = flights.distance / flights.air_time * 60\n",
"# flights$\n",
"flights['gain'] = flights['arr_delay'] - flights['dep_delay']\n",
"flights['speed'] = flights['distance'] / flights['air_time'] * 60\n",
"flights"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tail_num</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">517</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">830</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N14228</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1545</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">533</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">850</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N24211</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1714</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">542</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">923</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N619AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1141</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MIA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">544</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1004</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N804JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">725</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BQN</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">812</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N668DN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">461</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">740</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N39463</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1696</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">555</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">913</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N516JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">507</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">FLL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">709</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EV</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N829AS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5708</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAD</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">557</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">838</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N593JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">79</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MCO</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">558</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">753</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N3ALAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">301</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ORD</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">gain</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">speed</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1400</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">370.044052863</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">227</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1416</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">374.273127753</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">160</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1089</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">42</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">31</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">408.375</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">183</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1576</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">516.721311475</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">116</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">762</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">394.137931034</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">150</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">719</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">287.6</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">158</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1065</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">55</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">24</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">404.430379747</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">53</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">229</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">259.245283019</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">140</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">944</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">404.571428571</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">138</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">733</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">58</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">318.695652174</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[336776 rows x 19 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 14,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttail_num\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\tgain\tint\n",
"\tspeed\tfloat\n",
"\n",
"Rows: 336776\n",
"\n",
"Data:\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 1 | 2013 | 1 | 1 | 517 | 2 | 830 | 11 | UA |\n",
"| 2 | 2013 | 1 | 1 | 533 | 4 | 850 | 20 | UA |\n",
"| 3 | 2013 | 1 | 1 | 542 | 2 | 923 | 33 | AA |\n",
"| 4 | 2013 | 1 | 1 | 544 | -1 | 1004 | -18 | B6 |\n",
"| 5 | 2013 | 1 | 1 | 554 | -6 | 812 | -25 | DL |\n",
"| 6 | 2013 | 1 | 1 | 554 | -4 | 740 | 12 | UA |\n",
"| 7 | 2013 | 1 | 1 | 555 | -5 | 913 | 19 | B6 |\n",
"| 8 | 2013 | 1 | 1 | 557 | -3 | 709 | -14 | EV |\n",
"| 9 | 2013 | 1 | 1 | 557 | -3 | 838 | -8 | B6 |\n",
"| 10 | 2013 | 1 | 1 | 558 | -2 | 753 | 8 | AA |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+----------+--------+--------+------+----------+----------+------+--------+------+\n",
"| tail_num | flight | origin | dest | air_time | distance | hour | minute | gain |\n",
"+----------+--------+--------+------+----------+----------+------+--------+------+\n",
"| N14228 | 1545 | EWR | IAH | 227 | 1400 | 5 | 17 | 9 |\n",
"| N24211 | 1714 | LGA | IAH | 227 | 1416 | 5 | 33 | 16 |\n",
"| N619AA | 1141 | JFK | MIA | 160 | 1089 | 5 | 42 | 31 |\n",
"| N804JB | 725 | JFK | BQN | 183 | 1576 | 5 | 44 | -17 |\n",
"| N668DN | 461 | LGA | ATL | 116 | 762 | 5 | 54 | -19 |\n",
"| N39463 | 1696 | EWR | ORD | 150 | 719 | 5 | 54 | 16 |\n",
"| N516JB | 507 | EWR | FLL | 158 | 1065 | 5 | 55 | 24 |\n",
"| N829AS | 5708 | LGA | IAD | 53 | 229 | 5 | 57 | -11 |\n",
"| N593JB | 79 | JFK | MCO | 140 | 944 | 5 | 57 | -5 |\n",
"| N3ALAA | 301 | LGA | ORD | 138 | 733 | 5 | 58 | 10 |\n",
"+----------+--------+--------+------+----------+----------+------+--------+------+\n",
"+---------------+\n",
"| speed |\n",
"+---------------+\n",
"| 370.044052863 |\n",
"| 374.273127753 |\n",
"| 408.375 |\n",
"| 516.721311475 |\n",
"| 394.137931034 |\n",
"| 287.6 |\n",
"| 404.430379747 |\n",
"| 259.245283019 |\n",
"| 404.571428571 |\n",
"| 318.695652174 |\n",
"| ... |\n",
"+---------------+\n",
"[336776 rows x 19 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 14
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Like Pandas, SFrame does not (yet) expose a mutate method."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# R: \n",
"# transmute(flights,\n",
"# gain = arr_delay - dep_delay,\n",
"# gain_per_hour = gain / (air_time / 60)\n",
"# )\n",
"# pandas: \n",
"# flights['gain'] = flights.arr_delay - flights.dep_delay\n",
"# flights['gain_per_hour'] = flights.gain / (flights.air_time / 60)\n",
"# flights[['gain', 'gain_per_hour']]\n",
"flights['gain'] = flights['arr_delay'] - flights['dep_delay']\n",
"flights['gain_per_hour'] = flights['gain'] / (flights['air_time'] / 60)\n",
"flights[['gain', 'gain_per_hour']]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">gain</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">gain_per_hour</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2.37885462555</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4.22907488987</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">31</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11.625</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5.5737704918</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-9.8275862069</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6.4</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">24</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9.11392405063</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-12.4528301887</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2.14285714286</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4.34782608696</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[336776 rows x 2 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 15,
"text": [
"Columns:\n",
"\tgain\tint\n",
"\tgain_per_hour\tfloat\n",
"\n",
"Rows: 336776\n",
"\n",
"Data:\n",
"+------+----------------+\n",
"| gain | gain_per_hour |\n",
"+------+----------------+\n",
"| 9 | 2.37885462555 |\n",
"| 16 | 4.22907488987 |\n",
"| 31 | 11.625 |\n",
"| -17 | -5.5737704918 |\n",
"| -19 | -9.8275862069 |\n",
"| 16 | 6.4 |\n",
"| 24 | 9.11392405063 |\n",
"| -11 | -12.4528301887 |\n",
"| -5 | -2.14285714286 |\n",
"| 10 | 4.34782608696 |\n",
"| ... | ... |\n",
"+------+----------------+\n",
"[336776 rows x 2 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 15
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Summarize values"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"flights['dep_delay'].mean()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 16,
"text": [
"12.639070257304654"
]
}
],
"prompt_number": 16
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Randomly sample rows"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: sample_n(flights, 10)\n",
"# pandas: flights.loc[np.random.choice(flights.index, 10)]\n",
"flights.sample(.1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">X1</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr_delay</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">carrier</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tail_num</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flight</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">origin</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">544</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1004</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N804JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">725</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BQN</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">554</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">812</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N668DN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">461</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">559</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">0</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">702</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N708JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1806</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BOS</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">22</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">602</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">821</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">16</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N730MQ</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4401</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DTW</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">23</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">606</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">858</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N633AA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1895</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MIA</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">38</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">628</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1016</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">29</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N33289</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1665</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LAX</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">49</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">645</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">815</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">B6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N796JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">102</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">JFK</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BUF</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">68</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">659</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">959</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N838UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">960</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">RSW</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">75</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">717</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">850</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">FL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N978AT</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">850</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">LGA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">MKE</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">90</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">739</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">0</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1104</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">26</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">UA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N37408</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1479</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">EWR</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" </tr>\n",
"</table>\n",
"<table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">air_time</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">distance</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">hour</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">minute</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">gain</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">speed</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">gain_per_hour</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">183</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1576</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">516.721311475</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5.5737704918</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">116</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">762</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">54</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">394.137931034</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-9.8275862069</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">187</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">59</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">255.0</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5.45454545455</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">105</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">502</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">19</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">286.857142857</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10.8571428571</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">152</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1085</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">428.289473684</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-3.15789473684</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">366</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2454</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">31</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">402.295081967</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5.08196721311</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">63</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">301</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">45</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">286.666666667</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6.66666666667</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">164</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1068</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">59</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">390.731707317</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2.92682926829</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">134</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">738</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">13</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">330.447761194</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5.82089552239</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">249</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1400</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">39</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">26</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">337.34939759</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6.26506024096</td>\n",
" </tr>\n",
"</table>\n",
"[? rows x 20 columns]<br/>Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.<br/>You can use len(sf) to force materialization.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 17,
"text": [
"Columns:\n",
"\tX1\tstr\n",
"\tyear\tint\n",
"\tmonth\tint\n",
"\tday\tint\n",
"\tdep_time\tint\n",
"\tdep_delay\tint\n",
"\tarr_time\tint\n",
"\tarr_delay\tint\n",
"\tcarrier\tstr\n",
"\ttail_num\tstr\n",
"\tflight\tint\n",
"\torigin\tstr\n",
"\tdest\tstr\n",
"\tair_time\tint\n",
"\tdistance\tint\n",
"\thour\tint\n",
"\tminute\tint\n",
"\tgain\tint\n",
"\tspeed\tfloat\n",
"\tgain_per_hour\tfloat\n",
"\n",
"Rows: Unknown\n",
"\n",
"Data:\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| X1 | year | month | day | dep_time | dep_delay | arr_time | arr_delay | carrier |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"| 4 | 2013 | 1 | 1 | 544 | -1 | 1004 | -18 | B6 |\n",
"| 5 | 2013 | 1 | 1 | 554 | -6 | 812 | -25 | DL |\n",
"| 16 | 2013 | 1 | 1 | 559 | 0 | 702 | -4 | B6 |\n",
"| 22 | 2013 | 1 | 1 | 602 | -3 | 821 | 16 | MQ |\n",
"| 23 | 2013 | 1 | 1 | 606 | -4 | 858 | -12 | AA |\n",
"| 38 | 2013 | 1 | 1 | 628 | -2 | 1016 | 29 | UA |\n",
"| 49 | 2013 | 1 | 1 | 645 | -2 | 815 | 5 | B6 |\n",
"| 68 | 2013 | 1 | 1 | 659 | -1 | 959 | -9 | UA |\n",
"| 75 | 2013 | 1 | 1 | 717 | -3 | 850 | 10 | FL |\n",
"| 90 | 2013 | 1 | 1 | 739 | 0 | 1104 | 26 | UA |\n",
"+----+------+-------+-----+----------+-----------+----------+-----------+---------+\n",
"+----------+--------+--------+------+----------+----------+------+--------+------+\n",
"| tail_num | flight | origin | dest | air_time | distance | hour | minute | gain |\n",
"+----------+--------+--------+------+----------+----------+------+--------+------+\n",
"| N804JB | 725 | JFK | BQN | 183 | 1576 | 5 | 44 | -17 |\n",
"| N668DN | 461 | LGA | ATL | 116 | 762 | 5 | 54 | -19 |\n",
"| N708JB | 1806 | JFK | BOS | 44 | 187 | 5 | 59 | -4 |\n",
"| N730MQ | 4401 | LGA | DTW | 105 | 502 | 6 | 2 | 19 |\n",
"| N633AA | 1895 | EWR | MIA | 152 | 1085 | 6 | 6 | -8 |\n",
"| N33289 | 1665 | EWR | LAX | 366 | 2454 | 6 | 28 | 31 |\n",
"| N796JB | 102 | JFK | BUF | 63 | 301 | 6 | 45 | 7 |\n",
"| N838UA | 960 | EWR | RSW | 164 | 1068 | 6 | 59 | -8 |\n",
"| N978AT | 850 | LGA | MKE | 134 | 738 | 7 | 17 | 13 |\n",
"| N37408 | 1479 | EWR | IAH | 249 | 1400 | 7 | 39 | 26 |\n",
"+----------+--------+--------+------+----------+----------+------+--------+------+\n",
"+---------------+----------------+\n",
"| speed | gain_per_hour |\n",
"+---------------+----------------+\n",
"| 516.721311475 | -5.5737704918 |\n",
"| 394.137931034 | -9.8275862069 |\n",
"| 255.0 | -5.45454545455 |\n",
"| 286.857142857 | 10.8571428571 |\n",
"| 428.289473684 | -3.15789473684 |\n",
"| 402.295081967 | 5.08196721311 |\n",
"| 286.666666667 | 6.66666666667 |\n",
"| 390.731707317 | -2.92682926829 |\n",
"| 330.447761194 | 5.82089552239 |\n",
"| 337.34939759 | 6.26506024096 |\n",
"+---------------+----------------+\n",
"[? rows x 20 columns]\n",
"Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.\n",
"You can use len(sf) to force materialization."
]
}
],
"prompt_number": 17
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Currently we only expose the ability to sample at a given rate, rather than working with a fixed sample size."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#dplyr:\n",
"# planes <- group_by(flights, tailnum)\n",
"# delay <- summarise(planes,\n",
"# count = n(),\n",
"# dist = mean(distance, na.rm = TRUE),\n",
"# delay = mean(arr_delay, na.rm = TRUE))\n",
"# delay <- filter(delay, count > 20, dist < 2000)\n",
"# pandas: \n",
"# planes = flights.groupby(\"tailnum\")\n",
"# delay = planes.agg({\"year\": \"count\",\n",
"# \"distance\": \"mean\",\n",
"# \"arr_delay\": \"mean\"})\n",
"# delay.query(\"year > 20 & distance < 2000\")\n",
"delay = flights.groupby('tail_num', {'year_count': gl.aggregate.COUNT('year'), \n",
" 'mean_dist': gl.aggregate.MEAN('distance'), \n",
" 'mean_arr_t': gl.aggregate.MEAN('arr_delay')})\n",
"delay[delay['year_count'] > 20 and delay['mean_dist'] < 2000]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">tail_num</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year_count</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">mean_dist</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">mean_arr_t</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N3EHAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">74</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1227.09459459</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-5.35211267606</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N388DA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">104</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1574.21153846</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4.67307692308</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N938WN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1085.32</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7.68</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N622SW</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">818.2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N353NW</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">105</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">879.285714286</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4.42857142857</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N928DN</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1020.0</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">201.0</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N588JB</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">267</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1294.59925094</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11.2765151515</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N959UW</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">213</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">174.131455399</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1.02358490566</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N701GS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">23</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">831.782608696</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4.40909090909</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">N7BGAA</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1240.0</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">-21.5</td>\n",
" </tr>\n",
"</table>\n",
"[? rows x 4 columns]<br/>Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.<br/>You can use len(sf) to force materialization.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 18,
"text": [
"Columns:\n",
"\ttail_num\tstr\n",
"\tyear_count\tint\n",
"\tmean_dist\tfloat\n",
"\tmean_arr_t\tfloat\n",
"\n",
"Rows: Unknown\n",
"\n",
"Data:\n",
"+----------+------------+---------------+----------------+\n",
"| tail_num | year_count | mean_dist | mean_arr_t |\n",
"+----------+------------+---------------+----------------+\n",
"| N3EHAA | 74 | 1227.09459459 | -5.35211267606 |\n",
"| N388DA | 104 | 1574.21153846 | 4.67307692308 |\n",
"| N938WN | 25 | 1085.32 | 7.68 |\n",
"| N622SW | 5 | 818.2 | -2.0 |\n",
"| N353NW | 105 | 879.285714286 | 4.42857142857 |\n",
"| N928DN | 1 | 1020.0 | 201.0 |\n",
"| N588JB | 267 | 1294.59925094 | 11.2765151515 |\n",
"| N959UW | 213 | 174.131455399 | 1.02358490566 |\n",
"| N701GS | 23 | 831.782608696 | 4.40909090909 |\n",
"| N7BGAA | 2 | 1240.0 | -21.5 |\n",
"+----------+------------+---------------+----------------+\n",
"[? rows x 4 columns]\n",
"Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.\n",
"You can use len(sf) to force materialization."
]
}
],
"prompt_number": 18
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: \n",
"# destinations <- group_by(flights, dest)\n",
"# summarise(destinations,\n",
"# planes = n_distinct(tailnum),\n",
"# flights = n()\n",
"# )\n",
"# pandas\n",
"# destinations = flights.groupby('dest')\n",
"# destinations.agg({\n",
"# 'tailnum': lambda x: len(x.unique()),\n",
"# 'year': 'count'\n",
"# }).rename(columns={'tailnum': 'planes',\n",
"# 'year': 'flights'})\n",
"flights.groupby('dest', {'flights': gl.aggregate.COUNT('year')}) "
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dest</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">flights</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">ATL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17215</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">CHS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2884</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">TYS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">631</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DTW</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9384</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">RSW</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3537</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BOS</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">15508</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">DSM</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">569</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">BDL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">443</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">IAH</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7198</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">HNL</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">707</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[105 rows x 2 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 19,
"text": [
"Columns:\n",
"\tdest\tstr\n",
"\tflights\tint\n",
"\n",
"Rows: 105\n",
"\n",
"Data:\n",
"+------+---------+\n",
"| dest | flights |\n",
"+------+---------+\n",
"| ATL | 17215 |\n",
"| CHS | 2884 |\n",
"| TYS | 631 |\n",
"| DTW | 9384 |\n",
"| RSW | 3537 |\n",
"| BOS | 15508 |\n",
"| DSM | 569 |\n",
"| BDL | 443 |\n",
"| IAH | 7198 |\n",
"| HNL | 707 |\n",
"| ... | ... |\n",
"+------+---------+\n",
"[105 rows x 2 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 19
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We don't have count_unique yet, but we probably will soon."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: \n",
"# daily <- group_by(flights, year, month, day)\n",
"# (per_day <- summarise(daily, flights = n()))\n",
"# pandas\n",
"# daily = flights.groupby(['year', 'month', 'day'])\n",
"# per_day = daily['distance'].count()\n",
"# per_day\n",
"per_day = flights.groupby(['year', 'month', 'day'], {'per_day': gl.aggregate.COUNT('distance')})\n",
"per_day"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">per_day</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">21</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1000</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">912</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">992</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">17</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">848</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">973</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">896</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">686</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">20</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">970</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">23</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">965</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">917</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[365 rows x 4 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 20,
"text": [
"Columns:\n",
"\tday\tint\n",
"\tmonth\tint\n",
"\tyear\tint\n",
"\tper_day\tint\n",
"\n",
"Rows: 365\n",
"\n",
"Data:\n",
"+-----+-------+------+---------+\n",
"| day | month | year | per_day |\n",
"+-----+-------+------+---------+\n",
"| 21 | 11 | 2013 | 1000 |\n",
"| 5 | 5 | 2013 | 912 |\n",
"| 3 | 4 | 2013 | 992 |\n",
"| 17 | 2 | 2013 | 848 |\n",
"| 28 | 8 | 2013 | 973 |\n",
"| 12 | 5 | 2013 | 896 |\n",
"| 14 | 9 | 2013 | 686 |\n",
"| 20 | 3 | 2013 | 970 |\n",
"| 23 | 4 | 2013 | 965 |\n",
"| 14 | 4 | 2013 | 917 |\n",
"| ... | ... | ... | ... |\n",
"+-----+-------+------+---------+\n",
"[365 rows x 4 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 20
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: (per_month <- summarise(per_day, flights = sum(flights)))\n",
"# pandas: per_month = per_day.groupby(level=['year', 'month']).sum()\n",
"per_month = per_day.groupby(['year', 'month'], gl.aggregate.SUM('per_day'))\n",
"per_month"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Sum of per_day</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">27574</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">5</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28796</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28330</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">1</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">27004</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">27268</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28135</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">3</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28834</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">24951</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">10</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28889</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28243</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">...</td>\n",
" </tr>\n",
"</table>\n",
"[12 rows x 3 columns]<br/>Note: Only the head of the SFrame is printed.<br/>You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 21,
"text": [
"Columns:\n",
"\tmonth\tint\n",
"\tyear\tint\n",
"\tSum of per_day\tint\n",
"\n",
"Rows: 12\n",
"\n",
"Data:\n",
"+-------+------+----------------+\n",
"| month | year | Sum of per_day |\n",
"+-------+------+----------------+\n",
"| 9 | 2013 | 27574 |\n",
"| 5 | 2013 | 28796 |\n",
"| 4 | 2013 | 28330 |\n",
"| 1 | 2013 | 27004 |\n",
"| 11 | 2013 | 27268 |\n",
"| 12 | 2013 | 28135 |\n",
"| 3 | 2013 | 28834 |\n",
"| 2 | 2013 | 24951 |\n",
"| 10 | 2013 | 28889 |\n",
"| 6 | 2013 | 28243 |\n",
"| ... | ... | ... |\n",
"+-------+------+----------------+\n",
"[12 rows x 3 columns]\n",
"Note: Only the head of the SFrame is printed.\n",
"You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns."
]
}
],
"prompt_number": 21
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: (per_year <- summarise(per_month, flights = sum(flights)))\n",
"# pandas: per_year = per_month.sum()\n",
"per_year = per_month['Sum of per_day'].sum()\n",
"per_year"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 22,
"text": [
"336776"
]
}
],
"prompt_number": 22
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chaining"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"SFrame's don't yet support some of the chaining that dplyr provides. In this case we need to create a new variable."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# dplyr: \n",
"# flights %>%\n",
"# group_by(year, month, day) %>%\n",
"# select(arr_delay, dep_delay) %>%\n",
"# summarise(\n",
"# arr = mean(arr_delay, na.rm = TRUE),\n",
"# dep = mean(dep_delay, na.rm = TRUE)\n",
"# ) %>%\n",
"# filter(arr > 30 | dep > 30)\n",
"# pandas: \n",
"# (\n",
"# flights.groupby(['year', 'month', 'day'])\n",
"# [['arr_delay', 'dep_delay']]\n",
"# .mean()\n",
"# .query('arr_delay > 30 | dep_delay > 30')\n",
"# )\n",
"d = flights.groupby(['year', 'month', 'day'], {'arr': gl.aggregate.MEAN('arr_delay'), \n",
" 'dep': gl.aggregate.MEAN('dep_delay')})\n",
"d[d['arr'] > 30 or d['dep'] > 30] \n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
" <tr>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">day</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">month</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">year</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">dep</th>\n",
" <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">arr</th>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">40.5268935236</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">35.2030735456</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">8</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">34.6918976546</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">43.313641246</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">22</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">7</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">46.6670467503</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">62.7634032634</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">35.9507658643</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">37.6480263158</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">18</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">34.9153605016</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">36.0284810127</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">25</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">4</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">23.3395638629</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">33.68125</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">30</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">6</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">44.1881785283</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">43.5102781137</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">14</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">28.3615520282</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">46.3975044563</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">12</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">9</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">49.95875</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">58.9124183007</td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">11</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">2013</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">39.0735981308</td>\n",
" <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">36.2900943396</td>\n",
" </tr>\n",
"</table>\n",
"[? rows x 5 columns]<br/>Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.<br/>You can use len(sf) to force materialization.\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 23,
"text": [
"Columns:\n",
"\tday\tint\n",
"\tmonth\tint\n",
"\tyear\tint\n",
"\tdep\tfloat\n",
"\tarr\tfloat\n",
"\n",
"Rows: Unknown\n",
"\n",
"Data:\n",
"+-----+-------+------+---------------+---------------+\n",
"| day | month | year | dep | arr |\n",
"+-----+-------+------+---------------+---------------+\n",
"| 28 | 8 | 2013 | 40.5268935236 | 35.2030735456 |\n",
"| 9 | 8 | 2013 | 34.6918976546 | 43.313641246 |\n",
"| 22 | 7 | 2013 | 46.6670467503 | 62.7634032634 |\n",
"| 18 | 6 | 2013 | 35.9507658643 | 37.6480263158 |\n",
"| 18 | 4 | 2013 | 34.9153605016 | 36.0284810127 |\n",
"| 25 | 4 | 2013 | 23.3395638629 | 33.68125 |\n",
"| 30 | 6 | 2013 | 44.1881785283 | 43.5102781137 |\n",
"| 14 | 12 | 2013 | 28.3615520282 | 46.3975044563 |\n",
"| 12 | 9 | 2013 | 49.95875 | 58.9124183007 |\n",
"| 11 | 2 | 2013 | 39.0735981308 | 36.2900943396 |\n",
"+-----+-------+------+---------------+---------------+\n",
"[? rows x 5 columns]\n",
"Note: Only the head of the SFrame is printed. This SFrame is lazily evaluated.\n",
"You can use len(sf) to force materialization."
]
}
],
"prompt_number": 23
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Other Data Sources"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"SFrames now support import/export with [Spark RDDs](http://spark.apache.org/docs/latest/programming-guide.html#resilient-distributed-datasets-rdds)."
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment