{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ``pandas`` for dummies" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "call = {'cat' : 'meow',\n", " 'dog' : 'bark',\n", " 'bird' : 'tweet',\n", " 'horse' : 'neigh',\n", " 'audience' : 'snore'}" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "s = pd.Series(call)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "audience snore\n", "bird tweet\n", "cat meow\n", "dog bark\n", "horse neigh\n", "dtype: object" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'tweet'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s.loc['bird']" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "weight = {'cat' : 4,\n", " 'dog' : 14,\n", " 'bird' : 0.2,\n", " 'horse' : 500,\n", " 'audience' : 70}" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | call | \n", "weight | \n", "
---|---|---|
audience | \n", "snore | \n", "70.0 | \n", "
bird | \n", "tweet | \n", "0.2 | \n", "
cat | \n", "meow | \n", "4.0 | \n", "
dog | \n", "bark | \n", "14.0 | \n", "
horse | \n", "neigh | \n", "500.0 | \n", "