Skip to content

Instantly share code, notes, and snippets.

@den-run-ai
Last active June 9, 2016 20:50
Show Gist options
  • Save den-run-ai/12379b62ef6eec9252f4c9a77e46e2b1 to your computer and use it in GitHub Desktop.
Save den-run-ai/12379b62ef6eec9252f4c9a77e46e2b1 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from string import ascii_letters as ascl\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"res = pd.DataFrame(np.array([''.join(_) for _ in \n",
" zip(ascl[:9],ascl[9:18],ascl[18:27])]).reshape((3,3)),\n",
" columns='ca cb cc'.split(),\n",
" index='ra rb rc'.split())"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>ca</th>\n",
" <th>cb</th>\n",
" <th>cc</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>ra</th>\n",
" <td>ajs</td>\n",
" <td>bkt</td>\n",
" <td>clu</td>\n",
" </tr>\n",
" <tr>\n",
" <th>rb</th>\n",
" <td>dmv</td>\n",
" <td>enw</td>\n",
" <td>fox</td>\n",
" </tr>\n",
" <tr>\n",
" <th>rc</th>\n",
" <td>gpy</td>\n",
" <td>hqz</td>\n",
" <td>irA</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ca cb cc\n",
"ra ajs bkt clu\n",
"rb dmv enw fox\n",
"rc gpy hqz irA"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>ca</th>\n",
" <th>cb</th>\n",
" <th>cc</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>rb</th>\n",
" <td>dmv</td>\n",
" <td>enw</td>\n",
" <td>fox</td>\n",
" </tr>\n",
" <tr>\n",
" <th>rc</th>\n",
" <td>gpy</td>\n",
" <td>hqz</td>\n",
" <td>irA</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ca cb cc\n",
"rb dmv enw fox\n",
"rc gpy hqz irA"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ix=None\n",
"for ixi in [res[col].str.contains('e|A') for col in res.columns]:\n",
" if ix is not None:\n",
" ix = ix | ixi\n",
" else:\n",
" ix = ixi\n",
"res[ix]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
},
"latex_envs": {
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
},
"widgets": {
"state": {},
"version": "1.1.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment