Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tableau_lab.csv
tableau_lab.xlsx
285 changes: 285 additions & 0 deletions lab_tableau.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"id": "6f66f9dc",
"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>Customer</th>\n",
" <th>State</th>\n",
" <th>Customer Lifetime Value</th>\n",
" <th>Response</th>\n",
" <th>Coverage</th>\n",
" <th>Education</th>\n",
" <th>Effective To Date</th>\n",
" <th>EmploymentStatus</th>\n",
" <th>Gender</th>\n",
" <th>Income</th>\n",
" <th>...</th>\n",
" <th>Months Since Policy Inception</th>\n",
" <th>Number of Open Complaints</th>\n",
" <th>Number of Policies</th>\n",
" <th>Policy Type</th>\n",
" <th>Policy</th>\n",
" <th>Renew Offer Type</th>\n",
" <th>Sales Channel</th>\n",
" <th>Total Claim Amount</th>\n",
" <th>Vehicle Class</th>\n",
" <th>Vehicle Size</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>BU79786</td>\n",
" <td>Washington</td>\n",
" <td>2763.519279</td>\n",
" <td>No</td>\n",
" <td>Basic</td>\n",
" <td>Bachelor</td>\n",
" <td>2/24/11</td>\n",
" <td>Employed</td>\n",
" <td>F</td>\n",
" <td>56274</td>\n",
" <td>...</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Corporate Auto</td>\n",
" <td>Corporate L3</td>\n",
" <td>Offer1</td>\n",
" <td>Agent</td>\n",
" <td>384.811147</td>\n",
" <td>Two-Door Car</td>\n",
" <td>Medsize</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>QZ44356</td>\n",
" <td>Arizona</td>\n",
" <td>6979.535903</td>\n",
" <td>No</td>\n",
" <td>Extended</td>\n",
" <td>Bachelor</td>\n",
" <td>1/31/11</td>\n",
" <td>Unemployed</td>\n",
" <td>F</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>42</td>\n",
" <td>0</td>\n",
" <td>8</td>\n",
" <td>Personal Auto</td>\n",
" <td>Personal L3</td>\n",
" <td>Offer3</td>\n",
" <td>Agent</td>\n",
" <td>1131.464935</td>\n",
" <td>Four-Door Car</td>\n",
" <td>Medsize</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>AI49188</td>\n",
" <td>Nevada</td>\n",
" <td>12887.431650</td>\n",
" <td>No</td>\n",
" <td>Premium</td>\n",
" <td>Bachelor</td>\n",
" <td>2/19/11</td>\n",
" <td>Employed</td>\n",
" <td>F</td>\n",
" <td>48767</td>\n",
" <td>...</td>\n",
" <td>38</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>Personal Auto</td>\n",
" <td>Personal L3</td>\n",
" <td>Offer1</td>\n",
" <td>Agent</td>\n",
" <td>566.472247</td>\n",
" <td>Two-Door Car</td>\n",
" <td>Medsize</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>WW63253</td>\n",
" <td>California</td>\n",
" <td>7645.861827</td>\n",
" <td>No</td>\n",
" <td>Basic</td>\n",
" <td>Bachelor</td>\n",
" <td>1/20/11</td>\n",
" <td>Unemployed</td>\n",
" <td>M</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>65</td>\n",
" <td>0</td>\n",
" <td>7</td>\n",
" <td>Corporate Auto</td>\n",
" <td>Corporate L2</td>\n",
" <td>Offer1</td>\n",
" <td>Call Center</td>\n",
" <td>529.881344</td>\n",
" <td>SUV</td>\n",
" <td>Medsize</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>HB64268</td>\n",
" <td>Washington</td>\n",
" <td>2813.692575</td>\n",
" <td>No</td>\n",
" <td>Basic</td>\n",
" <td>Bachelor</td>\n",
" <td>2/3/11</td>\n",
" <td>Employed</td>\n",
" <td>M</td>\n",
" <td>43836</td>\n",
" <td>...</td>\n",
" <td>44</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Personal Auto</td>\n",
" <td>Personal L1</td>\n",
" <td>Offer1</td>\n",
" <td>Agent</td>\n",
" <td>138.130879</td>\n",
" <td>Four-Door Car</td>\n",
" <td>Medsize</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 24 columns</p>\n",
"</div>"
],
"text/plain": [
" Customer State Customer Lifetime Value Response Coverage Education \\\n",
"0 BU79786 Washington 2763.519279 No Basic Bachelor \n",
"1 QZ44356 Arizona 6979.535903 No Extended Bachelor \n",
"2 AI49188 Nevada 12887.431650 No Premium Bachelor \n",
"3 WW63253 California 7645.861827 No Basic Bachelor \n",
"4 HB64268 Washington 2813.692575 No Basic Bachelor \n",
"\n",
" Effective To Date EmploymentStatus Gender Income ... \\\n",
"0 2/24/11 Employed F 56274 ... \n",
"1 1/31/11 Unemployed F 0 ... \n",
"2 2/19/11 Employed F 48767 ... \n",
"3 1/20/11 Unemployed M 0 ... \n",
"4 2/3/11 Employed M 43836 ... \n",
"\n",
" Months Since Policy Inception Number of Open Complaints Number of Policies \\\n",
"0 5 0 1 \n",
"1 42 0 8 \n",
"2 38 0 2 \n",
"3 65 0 7 \n",
"4 44 0 1 \n",
"\n",
" Policy Type Policy Renew Offer Type Sales Channel \\\n",
"0 Corporate Auto Corporate L3 Offer1 Agent \n",
"1 Personal Auto Personal L3 Offer3 Agent \n",
"2 Personal Auto Personal L3 Offer1 Agent \n",
"3 Corporate Auto Corporate L2 Offer1 Call Center \n",
"4 Personal Auto Personal L1 Offer1 Agent \n",
"\n",
" Total Claim Amount Vehicle Class Vehicle Size \n",
"0 384.811147 Two-Door Car Medsize \n",
"1 1131.464935 Four-Door Car Medsize \n",
"2 566.472247 Two-Door Car Medsize \n",
"3 529.881344 SUV Medsize \n",
"4 138.130879 Four-Door Car Medsize \n",
"\n",
"[5 rows x 24 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"\n",
"df=pd.read_csv('https://raw.githubusercontent.com/data-bootcamp-v4/data/main/we_fn_use_c_marketing_customer_value_analysis.csv')\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "d8e505bb",
"metadata": {},
"outputs": [],
"source": [
"df.to_csv('tableau_lab.csv', index=False, encoding='utf-8', sep=',', quotechar='\"', lineterminator='\\n')\n",
"df.isnull().sum()\n",
"df.to_excel('tableau_lab.xlsx')"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "432b97c0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['Suburban', 'Rural', 'Urban'], dtype=object)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Location Code'].unique()"
]
}
],
"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.13.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added tableau.twbx
Binary file not shown.