# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda root]
#     language: python
#     name: conda-root-py
# ---

import itertools
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# +
items =[8,3,1,8,6,5,10,1,8,1]
def Counts (items):
    countsOfItems={}
    for item in items:
        if not (item in countsOfItems):
            countsOfItems[item]=1
        else:
            countsOfItems[item]+=1
    for (item,count) in countsOfItems.items():
        print(item, count/len(items))
    return countsOfItems
print(Counts(items))

plt.hist(items)
plt.xlim(1,10)
plt.show()

plt.hist(items, normed=1)
plt.xlim(1,10)
plt.show()

plt.hist(items, cumulative= True)
plt.xlim(1,10)
plt.show()
# -

#

# +
dataInMeters=pd.read_table('length_meters.csv', header= None)

plt.hist(dataInMeters)
plt.xlabel("Guesses in meters")

plt.show()
plt.figure()
dataInFeet= pd.read_table('length_feet.csv', header=None)
dataInFeet['m']=dataInFeet[0]*0.3048
plt.hist(dataInFeet['m'])
plt.xlabel("Guesses in feet")
plt.xlim(5,40)
plt.show()
# -

data_snowfall= pd.read_table('snowfall.csv', header= None)
data_snowfall.head()
plt.figure()
plt.hist(data_snowfall, bins= 15)
plt.axvline(data_snowfall[0].mean(), color='red', linewidth=2, label = 'Mean')
plt.axvline(data_snowfall[0].median(),color = 'green', linewidth=2, label = 'Median')
plt.legend()
plt.show()

# +
data_smoking=pd.read_table('smoking.csv')

data_smoking['ExSmokers'] = data_smoking['ExSmokers']*1
plt.boxplot([data_smoking['Smokers'],data_smoking['ExSmokers']])
plt.show()
# -

data_rats = pd.read_table('rat_lifespan.csv')
data_rats.head()
plt.figure()
plt.hist(data_rats['Diet'])
plt.show()
plt.figure()
data_rats['NoDiet'].hist(bins=10)
plt.xlim(0,1600)
plt.show()
plt.figure()
plt.hist(data_rats['Diet'])
data_rats['NoDiet'].hist()
plt.show()

data_births= pd.read_table('birth_rates.csv')
data_births.head()
plt.scatter(data_births['Year'], data_births['Birthrate'])
plt.show()

StarcoderdataJupyterScriptsDedupFiltered