{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "POLEFILE='examples_data/polar_vectors.csv'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "dipole=pd.read_csv(POLEFILE,index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "tripole=dipole.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "tripole['rconA']=dipole.max(axis=1)\n",
    "tripole['rconB']=dipole.min(axis=1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "tripole.columns=['conservative','liberal','incona','inconb']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['conservative', 'liberal', 'incona', 'inconb'], dtype='object')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tripole.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "tripole.to_csv('examples_data/quad_polar_vectors.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>conservative</th>\n",
       "      <th>liberal</th>\n",
       "      <th>incona</th>\n",
       "      <th>inconb</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>abany</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abdefctw</th>\n",
       "      <td>always wrong</td>\n",
       "      <td>not wrong at all</td>\n",
       "      <td>not wrong at all</td>\n",
       "      <td>always wrong</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abdefect</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abhlth</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abnomore</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abpoor</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abpoorw</th>\n",
       "      <td>always wrong</td>\n",
       "      <td>not wrong at all</td>\n",
       "      <td>not wrong at all</td>\n",
       "      <td>always wrong</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>abrape</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>absingle</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>colcom</th>\n",
       "      <td>fired</td>\n",
       "      <td>not fired</td>\n",
       "      <td>not fired</td>\n",
       "      <td>fired</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>comfort</th>\n",
       "      <td>strongly agree</td>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>godchnge</th>\n",
       "      <td>believe now, always have</td>\n",
       "      <td>don't believe now, never have</td>\n",
       "      <td>don't believe now, never have</td>\n",
       "      <td>believe now, always have</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>libmil</th>\n",
       "      <td>not remove</td>\n",
       "      <td>remove</td>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>polabuse</th>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>spkmil</th>\n",
       "      <td>allowed</td>\n",
       "      <td>not allowed</td>\n",
       "      <td>not allowed</td>\n",
       "      <td>allowed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>taxrich</th>\n",
       "      <td>about right</td>\n",
       "      <td>much too low</td>\n",
       "      <td>much too low</td>\n",
       "      <td>about right</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      conservative                        liberal  \\\n",
       "abany                           no                            yes   \n",
       "abdefctw              always wrong               not wrong at all   \n",
       "abdefect                        no                            yes   \n",
       "abhlth                          no                            yes   \n",
       "abnomore                        no                            yes   \n",
       "abpoor                          no                            yes   \n",
       "abpoorw               always wrong               not wrong at all   \n",
       "abrape                          no                            yes   \n",
       "absingle                        no                            yes   \n",
       "colcom                       fired                      not fired   \n",
       "comfort             strongly agree              strongly disagree   \n",
       "godchnge  believe now, always have  don't believe now, never have   \n",
       "libmil                  not remove                         remove   \n",
       "polabuse                        no                            yes   \n",
       "spkmil                     allowed                    not allowed   \n",
       "taxrich                about right                   much too low   \n",
       "\n",
       "                                 incona                    inconb  \n",
       "abany                               yes                        no  \n",
       "abdefctw               not wrong at all              always wrong  \n",
       "abdefect                            yes                        no  \n",
       "abhlth                              yes                        no  \n",
       "abnomore                            yes                        no  \n",
       "abpoor                              yes                        no  \n",
       "abpoorw                not wrong at all              always wrong  \n",
       "abrape                              yes                        no  \n",
       "absingle                            yes                        no  \n",
       "colcom                        not fired                     fired  \n",
       "comfort               strongly disagree            strongly agree  \n",
       "godchnge  don't believe now, never have  believe now, always have  \n",
       "libmil                           remove                not remove  \n",
       "polabuse                            yes                        no  \n",
       "spkmil                      not allowed                   allowed  \n",
       "taxrich                    much too low               about right  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tripole[tripole.liberal==tripole.incona]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>conservative</th>\n",
       "      <th>liberal</th>\n",
       "      <th>incona</th>\n",
       "      <th>inconb</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>bible</th>\n",
       "      <td>inspired word</td>\n",
       "      <td>book of fables</td>\n",
       "      <td>inspired word</td>\n",
       "      <td>book of fables</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>colmil</th>\n",
       "      <td>not fired</td>\n",
       "      <td>not allowed</td>\n",
       "      <td>not fired</td>\n",
       "      <td>not allowed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>conlabor</th>\n",
       "      <td>hardly any</td>\n",
       "      <td>a great deal</td>\n",
       "      <td>hardly any</td>\n",
       "      <td>a great deal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>grass</th>\n",
       "      <td>not legal</td>\n",
       "      <td>legal</td>\n",
       "      <td>not legal</td>\n",
       "      <td>legal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gunlaw</th>\n",
       "      <td>oppose</td>\n",
       "      <td>favor</td>\n",
       "      <td>oppose</td>\n",
       "      <td>favor</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intmil</th>\n",
       "      <td>very interested</td>\n",
       "      <td>not at all interested</td>\n",
       "      <td>very interested</td>\n",
       "      <td>not at all interested</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>libcom</th>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>libhomo</th>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>libmslm</th>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "      <td>remove</td>\n",
       "      <td>not remove</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>maboygrl</th>\n",
       "      <td>true</td>\n",
       "      <td>false</td>\n",
       "      <td>true</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>owngun</th>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>pillok</th>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>pilloky</th>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>pray</th>\n",
       "      <td>several times a day</td>\n",
       "      <td>never</td>\n",
       "      <td>several times a day</td>\n",
       "      <td>never</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>prayer</th>\n",
       "      <td>disapprove</td>\n",
       "      <td>approve</td>\n",
       "      <td>disapprove</td>\n",
       "      <td>approve</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>prayfreq</th>\n",
       "      <td>several times a day</td>\n",
       "      <td>never</td>\n",
       "      <td>several times a day</td>\n",
       "      <td>never</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>religcon</th>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>religint</th>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "      <td>strongly disagree</td>\n",
       "      <td>strongly agree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>reliten</th>\n",
       "      <td>strong</td>\n",
       "      <td>no religion</td>\n",
       "      <td>strong</td>\n",
       "      <td>no religion</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rowngun</th>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>shotgun</th>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>spkcom</th>\n",
       "      <td>not allowed</td>\n",
       "      <td>allowed</td>\n",
       "      <td>not allowed</td>\n",
       "      <td>allowed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>viruses</th>\n",
       "      <td>definitely true</td>\n",
       "      <td>definitely not true</td>\n",
       "      <td>definitely true</td>\n",
       "      <td>definitely not true</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 conservative                liberal               incona  \\\n",
       "bible           inspired word         book of fables        inspired word   \n",
       "colmil              not fired            not allowed            not fired   \n",
       "conlabor           hardly any           a great deal           hardly any   \n",
       "grass               not legal                  legal            not legal   \n",
       "gunlaw                 oppose                  favor               oppose   \n",
       "intmil        very interested  not at all interested      very interested   \n",
       "libcom                 remove             not remove               remove   \n",
       "libhomo                remove             not remove               remove   \n",
       "libmslm                remove             not remove               remove   \n",
       "maboygrl                 true                  false                 true   \n",
       "owngun                    yes                     no                  yes   \n",
       "pillok      strongly disagree         strongly agree    strongly disagree   \n",
       "pilloky     strongly disagree         strongly agree    strongly disagree   \n",
       "pray      several times a day                  never  several times a day   \n",
       "prayer             disapprove                approve           disapprove   \n",
       "prayfreq  several times a day                  never  several times a day   \n",
       "religcon    strongly disagree         strongly agree    strongly disagree   \n",
       "religint    strongly disagree         strongly agree    strongly disagree   \n",
       "reliten                strong            no religion               strong   \n",
       "rowngun                   yes                     no                  yes   \n",
       "shotgun                   yes                     no                  yes   \n",
       "spkcom            not allowed                allowed          not allowed   \n",
       "viruses       definitely true    definitely not true      definitely true   \n",
       "\n",
       "                         inconb  \n",
       "bible            book of fables  \n",
       "colmil              not allowed  \n",
       "conlabor           a great deal  \n",
       "grass                     legal  \n",
       "gunlaw                    favor  \n",
       "intmil    not at all interested  \n",
       "libcom               not remove  \n",
       "libhomo              not remove  \n",
       "libmslm              not remove  \n",
       "maboygrl                  false  \n",
       "owngun                       no  \n",
       "pillok           strongly agree  \n",
       "pilloky          strongly agree  \n",
       "pray                      never  \n",
       "prayer                  approve  \n",
       "prayfreq                  never  \n",
       "religcon         strongly agree  \n",
       "religint         strongly agree  \n",
       "reliten             no religion  \n",
       "rowngun                      no  \n",
       "shotgun                      no  \n",
       "spkcom                  allowed  \n",
       "viruses     definitely not true  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tripole[tripole.liberal==tripole.inconb]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
