<jupyter_start><jupyter_text>Tips  Introduction:This exercise was created based on the tutorial and documentation from [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/index.html)  The dataset being used is tips from Seaborn. Step 1. Import the necessary libraries:<jupyter_code>import pandas as pd
import numpy as np

# visualization libraries
import matplotlib.pyplot as plt
import seaborn as sns

# set seaborn style to white
sns.set_style("white")<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/07_Visualization/Tips/tips.csv).   Step 3. Assign it to a variable called tips<jupyter_code>tips = pd.read_csv('tips.csv')
tips.head()<jupyter_output><empty_output><jupyter_text>Step 4. Delete the Unnamed 0 column<jupyter_code>del tips['Unnamed: 0']
tips.head()
#Orginizing data
total_bill = tips['total_bill']
tip = tips['tip']
sex = tips['sex']
smoker = tips['smoker']
day = tips['day']
time = tips['time']
size = tips['size']<jupyter_output><empty_output><jupyter_text>Step 5. Plot the total_bill column histogram<jupyter_code># create histogram
plt.hist(total_bill)

#labeling x and y axis
plt.xlabel('Value')#label x
plt.ylabel('Frequency')#label y
plt.title('Total Bill') #adding title of the graph

sns.despine()# take out the right and upper borders

#second one looks much better
# create histogram
ttbill = sns.distplot(tips.total_bill);

#labeling x and y axis
plt.xlabel('Value')#label x
plt.ylabel('Frequency')#label y
plt.title('Total Bill') #adding title of the graph

# take out the right and upper borders
sns.despine()<jupyter_output><empty_output><jupyter_text>Step 6. Create a scatter plot presenting the relationship between total_bill and tip<jupyter_code>plt.scatter(total_bill,tip)
#labeling x and y axis
plt.xlabel('Total Bill')#label x
plt.ylabel('Tip')#label y
plt.title('Total Bill vs Tip') #adding title of the graph
plt.show()
#this way combines a scatter plot and histogram.
#like the first way better, not as much noise.
sns.jointplot(x = 'total_bill', y = 'tip', data = tips)<jupyter_output><empty_output><jupyter_text>Step 7.  Create one image with the relationship of total_bill, tip and size. Hint: It is just one function.<jupyter_code>sns.pairplot(tips)<jupyter_output><empty_output><jupyter_text>Step 8. Present the relationship between days and total_bill value<jupyter_code>plt.scatter(day, total_bill, color='red')
#labeling x and y axis
plt.xlabel('Day')#label x
plt.ylabel('Total Bill')#label y
plt.title('Day vs Total Bill') #adding title of the graph

sns.stripplot(x = "day", y = "total_bill", data = tips, jitter = True)
#jitter is usefull when there is a lot of points, prevents as much overlapp<jupyter_output><empty_output><jupyter_text>Step 9. Create a scatter plot with the day as the y-axis and tip as the x-axis, differ the dots by sex<jupyter_code>sns.stripplot(x = "tip", y = "day", hue = 'sex', data = tips, jitter = True)
#Hue used for seperating<jupyter_output><empty_output><jupyter_text>Step 10.  Create a box plot presenting the total_bill per day differetiation the time (Dinner or Lunch)<jupyter_code>sns.boxplot(x= 'day', y = 'total_bill', hue = 'time', data = tips)<jupyter_output><empty_output><jupyter_text>Step 11. Create two histograms of the tip value based for Dinner and Lunch. They must be side by side.<jupyter_code>#seborn style
sns.set(style = 'ticks')

#create facet grid
g = sns.FacetGrid(tips, col = 'time')
g.map(plt.hist, 'tip')<jupyter_output><empty_output><jupyter_text>Step 12. Create two scatterplots graphs, one for Male and another for Female, presenting the total_bill value and tip relationship, differing by smoker or no smoker They must be side by side.<jupyter_code>g2 = sns.FacetGrid(tips, col = "sex", hue = "smoker")
g2.map(plt.scatter, "total_bill", "tip", alpha =.7)

g2.add_legend();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1136826042726348, 'fraction_numerical': 0.005849440488301119, 'mean_word_length': 6.2032967032967035, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '433153', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1339, 'n_words': 414, 'path': '07_Visualization/Tips/Exercises.ipynb', 'repo_name': 'JorgeGomezPhD/pandas_exercises', 'size': '3932'}