# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
#Imports
import matplotlib.pyplot as plt
import seaborn as sns

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
import warnings
warnings.filterwarnings("ignore")



from wrangle import wrangle_telco
from prepare import scale_data





# -

# # explore_telco Exercises
# * Our scenario continues:
#
#     * As a customer analyst, I want to know who has spent the most money with us over their lifetime. I have monthly charges and tenure, so I think I will be able to use those two attributes as features to estimate total_charges. I need to do this within an average of $5.00 per customer.
#      - Do your work in a notebook named explore_telco. In addition, you should create a file named explore.py that contains the following functions for exploring your variables (features & target)

train, validate, test = wrangle_telco(split=True)
train.head()

# #### 1. Write a function named plot_variable_pairs that accepts a dataframe as input and plots all of the pairwise relationships along with the regression line for each pair.
#
#

sns.jointplot('tenure', 'monthly_charges', data=train, kind='reg', height=5);
plt.show()

 sns.jointplot('tenure', 'total_charges', data=train, kind='reg', height=5);
plt.show()



# #### 2. Write a function named months_to_years that accepts your telco churn dataframe and returns a dataframe with a new feature tenure_years, in complete years as a customer.
#
#

train['tenure_years'] = train.tenure / 12
train.tenure_years

# #### 3. Write a function named plot_categorical_and_continuous_vars that accepts your dataframe and the name of the columns that hold the continuous and categorical features and outputs 3 different plots for visualizing a categorical variable and a continuous variable.
#
#

cat_vars = []
quant_vars = ['tenure','total_charges','monthly_charges','tenure_years']

g = sns.PairGrid(train)
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter)



# #### 4. Save the functions you have written to create visualizations in a file named explore.py. Rewrite your notebook code so that you are using the functions imported from this file.
#
#

# #### 5. Explore your dataset with any other visualizations you think will be helpful.
#
#

sns.pairplot(train)



























StarcoderdataJupyterScriptsDedupFiltered