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

import numpy as np
import matplotlib
from matplotlib import pyplot as plt
import pandas as pd

data = pd.read_csv('ncbirth1450.csv')

data.head()

data

# +
x = np.array(data.iloc[:25, :-1])
print(x)


# -

new_data = data[data.GAINED != '38']
new_data

x = np.array(new_data.iloc[:25, :-1])
print(x)

new_data

new_data1 = new_data.copy() 

new_data = new_data[new_data.SMOKE != '#NULL!']
new_data

new_data(['LOW'], dtype="float64").sum()

new_data['DRINK'].sum()

table = new_data.groupby(['DRINK'])['SMOKE'].count()
table


new_data['MAGE'].mean()

new_data['WEEKS'].median()

new_data['TOUNCES'].std()

result = new_data.loc[:, ['SMOKE','TOUNCES']]

result

smoke_data =  result[result.SMOKE != '0']

smoke_data

df_nonsmoke = result[result.SMOKE != '1']
df_nonsmoke

Non_Smokers = (df_nonsmoke['TOUNCES'].values)
Smokers = (smoke_data['TOUNCES'].values)
print(('non-smokers mean is:'),df_nonsmoke['TOUNCES'].mean())
print(('smokers mean is :'),smoke_data['TOUNCES'].mean())
print(('non-smokers std is:'),df_nonsmoke['TOUNCES'].std())
print(('smokers std is :'),smoke_data['TOUNCES'].std())

fig, ax = plt.subplots(figsize=(12,6))
box_data = [Smokers,Non_Smokers]
ax.set_title('Smokers vs. Non-Smokers')
ax.set_ylabel('Ounces')
ax.boxplot(box_data,labels = ['Smokers','Non-Smokers'])


# +

 
value1 = [84,77,20,40,67,62,75,78,71,32,98,89,78,67,72,82,87,66,56,52]
value2=[62,5,91,25,35,32,96,99,3,90,95,34,27,55,100,15,71,11,37,21]
value3=[23,89,12,78,72,89,25,69,68,86,19,48,15,16,16,75,65,31,25,52]
value4=[59,73,73,16,81,61,88,98,10,87,29,72,16,23,72,88,78,99,75,30]
 
box_plot_data=[value1,value2,value3,value4]
plt.boxplot(box_plot_data)
plt.show()
# -

plt.boxplot(df_nonsmoke['TOUNCES'].values)

result1 = new_data.loc[:, ['SMOKE','TOUNCES','LOW']]

result1

p_nonsmoke = result1[result1.SMOKE != '1']
print(p_nonsmoke['LOW'].sum())
p_nonsmoke

p_smoke = result1[result1.SMOKE != '0']
p_smoke

p_smoke['LOW'].sum()

p_drink = new_data.loc[:, ['DRINK','LOW']]

p_drink

p_drink = p_drink[p_drink.DRINK != '0']
p_drink

p_drink['LOW'].sum()

p_notdrink = new_data.loc[:, ['DRINK','LOW']]
p_notdrink

p_notdrink = p_notdrink[p_notdrink.DRINK != '1']

p_notdrink

p_notdrink['LOW'].sum()

new_data

new_data.plot.scatter(x='RACEMOM', y='TOUNCES', s=50) #c=1, cmap = 'RdBu_r', s=50);

race_mom = new_data.loc[:, ['RACEMOM','TOUNCES']]
race_mom
                     

race_mom.plot.scatter(x=1, y='TOUNCES',c=1, cmap = 'RdBu_r', s=50);



StarcoderdataJupyterScriptsDedupFiltered