<jupyter_start><jupyter_text>Observations and Insights  Dependencies and starter code<jupyter_code># Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
import scipy.stats as st

# Study data files
mouse_metadata = "data/Mouse_metadata.csv"
study_results = "data/Study_results.csv"

# Read the mouse data and the study results
mouse_metadata = pd.read_csv(mouse_metadata)
study_results = pd.read_csv(study_results)

# Combine the data into a single dataset<jupyter_output><empty_output><jupyter_text>Summary statistics<jupyter_code># Generate a summary statistics table of mean, median, variance, standard deviation, and SEM of the tumor volume for each regimen

combined_data = pd.merge(mouse_metadata, study_results, how="left", on="Mouse ID")
grouped_data = combined_data.groupby(combined_data["Drug Regimen"])

mean_data = grouped_data["Tumor Volume (mm3)"]
summary_combined_data = pd.DataFrame({
    "Tumor Mean": mean_data.mean(),
    "Tumor Median": mean_data.median(),
    "Tumor Variance": mean_data.var(),
    "Tumor STD": mean_data.std(),
    "Tumor SEM": mean_data.sem(),
    "Rat Count": mean_data.count(),
    "Sex": grouped_data["Sex"]
})
#mean_data.head()
summary_combined_data<jupyter_output><empty_output><jupyter_text>Bar plots<jupyter_code># Generate a bar plot showing number of data points for each treatment regimen using pandas
rat_df = summary_combined_data["Rat Count"]

ax = rat_df.plot.bar(x="Drug Regimen", y="Rats", rot=0)
# Generate a bar plot showing number of data points for each treatment regimen using pyplot
drug_regimen = combined_data["Drug Regimen"].unique()
drug_rat_chart = plt.bar(drug_regimen, summary_combined_data["Rat Count"])
drug_rat_chart<jupyter_output><empty_output><jupyter_text>Pie plots<jupyter_code># Generate a pie plot showing the distribution of female versus male mice using pandas
gender_rats = combined_data.groupby("Sex")
#gender_rats["Drug Regimen"] = combined_data["Drug Regimen"]
gender_rats_df = pd.DataFrame({
    "Tumor Volume": gender_rats["Tumor Volume (mm3)"]
})
gender_rats_df.head()
genders = ["Female", "Male"]
#summary_combined_data["Genders"]
plt.pie(gender_rats_df, labels=genders,
        autopct="%1.1f%%", shadow=True, startangle=140)
# Generate a pie plot showing the distribution of female versus male mice using pyplot
combined_data.head()<jupyter_output><empty_output><jupyter_text>Quartiles, outliers and boxplots<jupyter_code># Calculate the final tumor volume of each mouse across four of the most promising treatment regimens. Calculate the IQR and quantitatively determine if there are any potential outliers. 
# Generate a box plot of the final tumor volume of each mouse across four regimens of interest<jupyter_output><empty_output><jupyter_text>Line and scatter plots<jupyter_code># Generate a line plot of time point versus tumor volume for a mouse treated with Capomulin
tumor_volume_df = pd.DataFrame({
    
})

# Generate a scatter plot of mouse weight versus average tumor volume for the Capomulin regimen
tumor_volume = combined_data["Tumor Volume (mm3)"]
rat_weight = combined_data["Weight (g)"]
plt.scatter(tumor_volume, rat_weight, marker="o", facecolors="red", edgecolors="black")
plt.title("Rat Weight vs Tumor")
plt.xlabel("Tumor Volume (mm3)")
plt.ylabel("Weight (g)")
# Calculate the correlation coefficient and linear regression model for mouse weight and average tumor volume for the Capomulin regimen<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09699769053117784, 'fraction_numerical': 0.002886836027713626, 'mean_word_length': 6.717149220489977, 'pattern_counts': {'":': 8, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '462142', 'license': 'ADSL', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1062, 'n_words': 330, 'path': 'Pymaceuticals/pymaceuticals_starter.ipynb', 'repo_name': 'MissWibbon/matplotlib', 'size': '3464'}