<jupyter_start><jupyter_text>Allergy  To Do:* Logistic regression https://towardsdatascience.com/building-a-logistic-regression-in-python-step-by-step-becd4d56c9c8<jupyter_code>'#1.Step: Load the need libs'
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from sklearn.metrics import confusion_matrix
from google.colab import files<jupyter_output><empty_output><jupyter_text>Sleep<jupyter_code>'#2.Step: Authorize colab to access the spread sheet'
from google.colab import auth
auth.authenticate_user()

import gspread
from oauth2client.client import GoogleCredentials

gc = gspread.authorize(GoogleCredentials.get_application_default())


wb = gc.open_by_url('https://docs.google.com/spreadsheets/d/11FQbz9iooNOWfljuoPLy914OfR0D10Kn4AKxe2KxR7o/edit#gid=0')

'#3.Step: Load the data from the speadsheet'
sheet = wb.worksheet('data')
data = sheet.get_all_values()

df = pd.DataFrame(data)

'#3.2.Step: Make the first row to header of the sheet'
headers = df.iloc[0]
df_new  = pd.DataFrame(df.values[1:], columns=headers)
'#3.3.Step: Convert string to date'
for el in ["sleep.start_time","sleep.end_time"]:
  df_new[el] = pd.to_datetime(df_new[el], format="%d.%m.%Y %H:%M")
'#3.4.Step. Convert duration to time object'
df_new["Duration"] = df_new["sleep.end_time"] - df_new["sleep.start_time"]
df_new.info()
# define the bins
bins = [pd.Timedelta(minutes = el) for el in range(120,540,15)]

# add the bins to the dataframe
df_new['Time Bin'] =pd.cut(df_new.Duration, bins, right=False)
'#4.Step: Replace bins with more readable labels'
df_new['Time Bin'] = df_new['Time Bin'].astype(str)
df_new_finish = df_new.replace(to_replace=r"\[0 days ", value='', regex=True)\
  .replace(to_replace=r", 0 days", value=' -', regex=True)\
  .replace(to_replace=r":00\)", value='', regex=True)\
  .replace(to_replace=r":00 ", value=' ', regex=True)

'#5.Step. Plot data as histogram'
# df_new_finish.groupby('Time Bin', as_index=True).count()["Duration"].plot(kind='bar')
grouped = df_new_finish.groupby('Time Bin', as_index=True).count()[["Duration"]]

'#6.Step: Export data to excel file'
grouped.to_excel('df.xlsx')
files.download('df.xlsx')<jupyter_output><empty_output><jupyter_text>Allergie<jupyter_code>'#2.Step: Authorize colab to access the spread sheet'
from google.colab import auth
auth.authenticate_user()

import gspread
from oauth2client.client import GoogleCredentials

gc = gspread.authorize(GoogleCredentials.get_application_default())


wb = gc.open_by_url('https://docs.google.com/spreadsheets/d/1M9EFViqVR_9a3p6SA4lJpGz-oAIFHdqelPdQ6m8Y_Uo/edit#gid=0')
dict_real = set(df_finsh['Wirklichkeit'])
dict_real = set(df_finsh['Wirklichkeit'])
dict_all = set(reversed_personal_dict.keys())
for el in ("Gustav","Svenja","Wirklichkeit"):
  dict_el = set(df_finsh[el])
  result = dict_all.difference(dict_el)
  print("===",el,"===")
  #Print missing categories
  missing=""
  for j in result:
    missing = missing +", "+reversed_personal_dict[j]
  print(missing)
'#3.Step: Load the data from the speadsheet'
sheet = wb.worksheet('data')
data = sheet.get_all_values()

df = pd.DataFrame(data)

'#3.2.Step: Make the first row to header of the sheet'
headers = df.iloc[0]
df_new  = pd.DataFrame(df.values[1:], columns=headers)

'#3.1.Step: Replace strings like istj with number'
personal_dict = {"intj":	1,
                "intp":	2,
                "entj":	3,
                "entp":	4,
                "infj":	5,
                "infp":	6,
                "enfj":	7,
                "enfp":	8,
                "istj":	9,
                "isfj":	10,
                "estj":	11,
                "esfj":	12,
                "istp":	13,
                "isfp":	14,
                "estp":	15,
                "esfp":	16,
              }
#Switch for key and values for label              
reversed_personal_dict = {value : key for (key, value) in personal_dict.items()}
        

df_finsh = df_new.replace(personal_dict)
df_finsh
df_finsh[['Wirklichkeit', 'Gustav','Svenja']]
y_true = df_finsh['Wirklichkeit']
y_pred = df_finsh['Gustav']
for el in ["Gustav","Svenja"]:
  conf_matrix = pd.crosstab(df_finsh['Wirklichkeit'], df_finsh[el], rownames=['Wirklichkeit'], colnames=[el])
  conf_matrix = conf_matrix.rename(columns=reversed_personal_dict,index=reversed_personal_dict)
  sns.heatmap(conf_matrix, annot=True,cmap="YlGnBu")
  plt.show()<jupyter_output><empty_output><jupyter_text>Show distribution<jupyter_code>df_new = df_new.astype({'Gustav_right': 'int32',"Svenja_right":'int32'})
df_new.info()
mean = df_new[["Svenja_right","Movie title"]].groupby(['Movie title']).mean()
std = df_new[["Svenja_right","Movie title"]].groupby(['Movie title']).std()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 30 entries, 0 to 29
Data columns (total 12 columns):
 #   Column               Non-Null Count  Dtype 
---  ------               --------------  ----- 
 0   No                   30 non-null     object
 1   Movie title          30 non-null     object
 2   Schauspielername     30 non-null     object
 3   Wirklichkeit         30 non-null     object
 4   Gustav               30 non-null     object
 5   Gustav_right         30 non-null     int32 
 6   Svenja               30 non-null     object
 7   Svenja_right         30 non-null     int32 
 8                        30 non-null     object
 9   Baseline_Guess       30 non-null     object
 10  Baseline_Guess_Type  30 non-null     object
 11  Basline_right        30 non-null     object
dtypes: int32(2), object(10)
memory usage: 2.7+ KB<jupyter_text>Pre-processing of df<jupyter_code>'#3.1.Step: Transpose the dataframe (switch rows with columns)'
df_t = df.T
'#3.2.Step: Make the first row to header of the sheet'
headers = df_t.iloc[0]
df_new  = pd.DataFrame(df_t.values[1:], columns=headers)

'#3.1.Step: Repalce n.a.n with nan'
df_nan = df_new.replace("n.a.n",np.nan)
'#3.2.Step: Drop rows with nan'
df_non = df_nan.dropna()
'#3.3.SteP: Convert the Datum column to datetime obj'
df_non["Datum_obj"] = pd.to_datetime(df_non["Datum"], format='%d.%m.%Y', errors='ignore')


'#3.4.Step: Replace all values to 0 ,1 '
df_non = df_non.replace({'n.a.n.':np.nan, 'FALSE':0, 'TRUE':1,'0':0, '1':1, 'keine':0, 'schwach':1 })
display(df_non)<jupyter_output><empty_output><jupyter_text>Pre-processing: Allergiesynt.<jupyter_code>## Clean the data
allergie_columns=['<NAME>',
 'juckende Haut nach Baden',
 'juckende Haut',
 'juckende Nase oder Schnupfen ',
 'juckende Augen ',
 'Starke Allergie ',
 'Allergietablette genommen ',
 'Ausschlag nach Joggen auf Brust und Rücken ',
 'Starke Allergie nach Schlafen',
 'Halsschmerzen ',
 'Gustav berührt mich Ausschlag auf Haut ',
 'Leichte hibbel Gesicht ',
 'Starker Ausschlag Rücken ',
 'Dunkle Augenringe',
 'Allergie Gräser',]

df_non[allergie_columns] = df_non[allergie_columns].replace({"FALSE":0,"1":1,"TRUE":1,"0":0,"n.a.n.":np.nan,"":0})

def get_unique_values_df(df):
  column_values = df.values.ravel()
  unique_values =  pd.unique(column_values)
  return(unique_values)
# df_nan = df_non.dropna()
# df_nan.shape<jupyter_output><empty_output><jupyter_text>Pre-process the pollen allergy<jupyter_code>def get_unique_values_df(df):
  column_values = df.values.ravel()
  unique_values =  pd.unique(column_values)
  list_unique = list(unique_values)
  '#Remove all date and Timestamp types'
  for x in list_unique[:]:
    if type(x)==str:    
      if "2020" in x:
        list_unique.pop(list_unique.index(x))
    if pd._libs.tslibs.timestamps.Timestamp==type(x):
      list_unique.pop(list_unique.index(x))
  return(list_unique)


get_unique_values_df(df_non)

# Comine all syntome
# df_nan = df_non.dropna()
# df_nan[allergie_columns].sum().plot.pie()



pollen = ['Ambrosia',
 'Ampfer',
 'Beifuß',
 'Birke',
 'Buche',
 'Eiche',
 'Erle',
 'Esche',
 'Gräser',
 'Hasel',
 'Pappel',
 'Roggen',
 'Ulme',
 'Wegerich',
 'Weide',]

df_non[pollen] = df_non[pollen].replace({"Keine":0,"Schwach":1,"mittel":1,"stark":1,'keine ':0})
# df_nan.to_excel('df_nan.xlsx')

# files.download('df_nan.xlsx')<jupyter_output><empty_output><jupyter_text>Check Pre-processing<jupyter_code>#Now there should be only ['', 0.0, 1.0, nan] in the df

get_unique_values_df(df_non)<jupyter_output><empty_output><jupyter_text>EDA<jupyter_code>import pprint
pp = pprint.PrettyPrinter(indent=4)
allergie_dict =  {i:item for i,item in enumerate(allergie_columns)}
pp.pprint(allergie_dict)
df_test = pd.DataFrame({"a":[1,0,0,0],"b":[1,1,0,0],"c":[1,0,0,0]})
df_test
def fn(row):
  """
  Combine serveral columns to see if one of the synptome appear.
  """
  if row.sum()>=1:
      return 1
  else:
      return 0

df_test['one_more_synptome'] = df_test.apply(fn, axis=1)
df_test
df_non[allergy_symptome].apply(fn, axis=1)
'#Select all row where allergy symptome where 1 and sum the columns ' 

allergy_symptome = [allergie_dict[x] for x in [0,1,2,3,4,5,7,8,10,11,12]]
#####################

#Create  a new column which contains if allergy syntomes appear or not
df_non["total_amount"] = df_non[allergy_symptome].apply(fn, axis=1)

'#Drop all allergie rows'
df_symptome = df_symptome.drop(columns=allergie_columns)
df_symptome_sum = df_symptome.drop(columns=["Datum","Datum_obj"]).sum(axis=0) 

df_result_symptome = pd.DataFrame.from_dict({"attribute":df_symptome_sum.keys(),
                                 "sum":df_symptome_sum.values
                                } )


'#Drop all row with a sum of ""'
df_result_symptome = df_result_symptome[df_result_symptome["sum"] != ""]
'#Select all rows with 0'
df_symptome_zero =  df_result_symptome[df_result_symptome["sum"] ==0]
print(list(df_symptome_zero["attribute"]))
######################
'Now we can check if a certian item is in the list'
'Nudelsuppe' in list(df_symptome_zero["attribute"])

'#Select all row !=0 and sort them'
df_symptome_1=  df_result_symptome[df_result_symptome["sum"] !=0].sort_values("sum",ascending=False)
'#Calculate percentage'
df_symptome_1["percent"]=df_symptome_1["sum"]/float(df_result_symptome[["sum"]].sum(axis=0))*100
df_symptome_1["percent"] = df_symptome_1["percent"].astype(float)
df_symptome_1["percent"]=df_symptome_1["percent"].round()
plt.pie(x=df_symptome_1["sum"],labels=df_symptome_1["attribute"])
df_symptome_1



df_result_symptome


import pprint
pp = pprint.PrettyPrinter(indent=4)
object_list = list(df_non.drop(columns=allergie_columns).keys())
object_dict =  {i:item for i,item in enumerate(object_list)}
pp.pprint(object_dict)
object_list.remove('Datum')
'#Select all object to find out which allergy sympotme it caused' 

object_item = object_dict[281]
#####################
df_symptome= df_non[df_non[object_item]==1]
'#Drop all allergie rows'
df_symptome = df_symptome.drop(columns=object_list)

df_symptome_sum = df_symptome.sum(axis=0) 

df_result_symptome = pd.DataFrame.from_dict({"attribute":df_symptome_sum.drop("Datum").keys(),
                                 "sum":df_symptome_sum.drop("Datum").values
                                } )


'#Drop all row with a sum of ""'
df_result_symptome = df_result_symptome[df_result_symptome["sum"] != ""]
'#Select all rows with 0'
df_symptome_zero =  df_result_symptome[df_result_symptome["sum"] ==0]
print(list(df_symptome_zero["attribute"]))
######################
'Now we can check if a certian item is in the list'
'Nudelsuppe' in list(df_symptome_zero["attribute"])

'#Select all row !=0 and sort them'
df_symptome_1=  df_result_symptome[df_result_symptome["sum"] !=0].sort_values("sum",ascending=False)
'#Calculate percentage'
df_symptome_1["percent"]=df_symptome_1["sum"]/float(df_result_symptome[["sum"]].sum(axis=0))*100
df_symptome_1["percent"] = df_symptome_1["percent"].astype(float)
df_symptome_1["percent"]=df_symptome_1["percent"].round()
plt.pie(x=df_symptome_1["sum"],labels=df_symptome_1["attribute"])
df_symptome_1

sum
### Make sum allergie
df_non['allergie_total'] = df_non[allergie_columns].sum(axis=1)

df_non.loc[df_non['allergie_total'] !=0.0, 'allergie_total_norm'] = 1
df_non['allergie_total_norm'] = df_non['allergie_total'].apply(lambda x: 1 if x >0.0 else 0)
df_non["allergie_total_norm"]
import os
os.listdir(os.getcwd())
df_con_pre.to_csv("test.csv")
from google.colab import files
files.download('test.csv') 
import scipy.stats as stats

def get_unique_values_df(df):
  column_values = df.values.ravel()
  unique_values =  pd.unique(column_values)
  print(unique_values)
#Remove all duplicate columns
df_nan = df_nan.loc[:,~df_nan.columns.duplicated()]
df_con = df_nan.drop(columns=["Datum_obj", "Datum"])  

df_con_pre = df_con.replace({"FALSE":0,"1":1,"TRUE":1,"0":0,"n.a.n.":np.nan,"":0})
get_unique_values_df(df_con_pre)

result_dict={}

for i,el in enumerate(df_con_pre.keys()[:257]):
  # print(i)
  #If the shape is only 1 that means we never observed the event
  if el!='':
    if (len(df_con_pre[el].unique())!=1):
      confusion_matrix = pd.crosstab(df_con_pre['allergie_total_norm'], df_con_pre[el], rownames=['allergie_total'], colnames=[el])
      # sns.heatmap(confusion_matrix, annot=True)
      # plt.show()
      #### That is wrong! Now I need to find all rows where only "Tomatensuppe" was differnt

      oddsratio, pvalue = stats.fisher_exact(confusion_matrix.values)
      result_dict[el]=pvalue
      # print(pvalue)

df_result = pd.DataFrame.from_dict(result_dict,columns=["pvalue"], orient='index')
df_result_index = df_result.reset_index()
df_sorted = df_result_index.sort_values(by=['pvalue'],ascending=False) 
not_allergy = df_sorted[df_sorted["pvalue"]<=0.1].shape[0]
print(f"Total: {df_sorted.shape[0]}")
print(f"allergy: {df_sorted.shape[0]-not_allergy}/{not_allergy}")
print(df_sorted[df_sorted["pvalue"]<=0.1].shape)
display(df_sorted[df_sorted["pvalue"]<=0.1].head(15))
display(df_sorted.head(15))
"""***
######################
Next steps:
 - Create a logicstical 
https://www.datacamp.com/community/tutorials/understanding-logistic-regression-python
"""

df_non[[el,"Datum"]][df_non[el]=="True"]
df_con_pre[el].unique()
df_con_pre.keys()[259:]<jupyter_output><empty_output><jupyter_text>Posture<jupyter_code>el = [0]
el
gesamt={"2020-07-26_bevore":[14.5,15,15,13,14,13,13,11.5,11,15,14,14,14,13.5,13],
        "2020-07-26_after":[12,12,12,12.5,12,13,12,12.5,12,13,12,12.5]}
 # Svenja
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
import pandas as pd
import seaborn as sns

right = np.array([11.5,11,15,14,14,14,13.5,13])
mean_right = np.mean(right)
std_right = np.std(right)
print(f"var_right:{std_right},:mean_right:{mean_right}")
left = np.array([9.5,14.5,15,15,13,14,13,13])
mean_left = np.mean(left)
std_left = np.std(left)
print(f"var_left:{std_left},:mean_left:{mean_left}")

### Create the Probability density function
plt.grid(True)
uebungen={"2020-07-26_uebungen":["Ball","Kopf_dehnen"],
         "2020-07-27_uebungen":["Türe","Ball","Kopf_dehnen"]}
gesamt={"2020-07-26_bevore":[14.5,15,15,13,14,13,13,11.5,11,15,14,14,14,13.5,13],
        "2020-07-26_after":[12,12,12,12.5,12,13,12,12.5,12,13,12,12.5],
        "2020-07-27_bevore":[10.5,11,11,10.5,11,11,11,10.5,11,11.5,11,11],
        "2020-07-27_after":[9, 9.5, 8., 9.5, 10, 10, 10.5, 11, 10.5, 11, 10, 10.5 ],
        "2020-07-28_bevore":[10,10,11,11,11.5,11,11.5,10,12,11,11.5,11],
        "2020-07-28_after":[9.5, 8, 9.5, 9.5, 9.5, 8.5, 8.5, 8, 8, 8., 8.5],
        "2020-07-29_bevore":[10, 9, 10, 10.5, 9,10, 10, 9.5, 9.5, 9, 10, 9.5],
        "2020-07-29_after":[10, 10.5, 9.5, 10, 9.5, 10, 9.5, 10,9, 9.5, 10, 10],
        "2020-12-06_bevore":[13.5,14.5,13.5,14.5,12.5,13,12,12],
        "2020-12-06_after":[12,11.5,11,10.5,11.5,11.5,11.5],
        }
mean = np.mean(gesamt["2020-07-26_bevore"])
std = np.std(gesamt["2020-07-26_bevore"])

for el in list(gesamt.keys()):
  print(f"##### {el} #####")
  print(f"std:{np.std(gesamt[el])},:mean:{np.mean(gesamt[el])}")
  ax = sns.distplot(gesamt[el],label=el)
  print(f"##############")
plt.legend()

# ax.axvline(35,c="b", linewidth = 3) #add a line to the graph
plt.show()

from google.colab import files
gesamt={"2020-07--26-before":[13,12.7,12.5,13,12.5,12.5,  12.3,12.1,12.2,12.6,12.6,12.6,0,0,0,0],
        "2020-07-26_after":[12.5,12.6,12.8,12.7,12.6,13.1,12.3,12.3,12.6,12.7,12.3,12.2,0,0,0,0],
        "2020-07-26_after_2":[12.6,12.4,12.7,12.3,12.6,12.5,11.8,12.2,12.5,11.9,12.5,12.5,0,0,0,0],
        "2020-07-27-before":[12, 11.6, 13, 12.5, 12.5, 12.3, 12.8, 12.2,    13.2, 12.3, 12.5, 11.9, 12.5, 12.5, 12.9, 12.3],
        "2020-07-27_after":[12.5, 11.8, 12.5, 11.8, 12.7, 12.4, 12.8, 12.6, 12.6, 12.7, 12.8, 12.6, 12.7, 13,0,0],}

for el in gesamt.keys():
    print(len(gesamt[el]))
df = pd.DataFrame.from_dict(gesamt)
df.to_excel('df.xlsx')
files.download('df.xlsx')
for el in list(df_proc_fin.keys()):
  print(el)
  df_proc_fin[el] = df_proc_fin[el].astype(float)
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
import pandas as pd
import seaborn as sns
'#2.Step: Authorize colab to access the spread sheet'
%matplotlib notebook
%matplotlib inline
from google.colab import auth
auth.authenticate_user()

import gspread
from oauth2client.client import GoogleCredentials

gc = gspread.authorize(GoogleCredentials.get_application_default())
wb = gc.open_by_url('https://docs.google.com/spreadsheets/d/1wkgMSGum811QOf3awF-cp_5-4vOc7RRBUFnqGpJFBNw/edit?usp=sharing')
'#3.Step: Load the measurement data  from the speadsheet'
sheet = wb.worksheet('data')
data = sheet.get_all_values()
df = pd.DataFrame(data)
'#4.Step: Combine the frist and second row (date and before|after)'
df.iloc[0] = df.iloc[0]+" - "+df.iloc[1]
'#4.1.Step: Drop the row with before| after'
df_proc = df.drop(df.index[1])
# display(df_proc.head())
'#4.2.Step: Drop column 0'
df_proc_drop = df.drop(columns=[0])
# display(df_proc_fin.head())
'#5.Step: Set first row as column name'
df_proc_fin = df_proc_drop.rename(columns=df_proc_drop.iloc[0]).drop([0,1])
display(df_proc_fin)

'# Load the exercise data from the spreadsheet'
sheet = wb.worksheet('exercise')
data = sheet.get_all_values()
df_exercise = pd.DataFrame(data)
df_exercise = df_exercise.rename(columns=df_exercise.iloc[0]).drop([0])
df_exercise.head()

# Visualize the data
for el in list(df_proc_fin.loc[:,:"Wednesday, 29 July 2020 - After"].keys()):
  print(f"##### {el} #####")
  df_proc_fin[el] = df_proc_fin[el].astype(float)
  print(f"std:{np.std(df_proc_fin[el].values)},:mean:{np.mean(df_proc_fin[el].values)}")
  ax = sns.distplot(df_proc_fin[el].values,label=el)
plt.legend()
import datetime
from datetime import date
import pandas as pd
import numpy as np
from plotly import __version__
%matplotlib inline

import plotly.offline as pyo
import plotly.graph_objs as go
from plotly.offline import iplot

import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot 


cf.go_offline()

def configure_plotly_browser_state():
  import IPython
  display(IPython.core.display.HTML('''
        <script src="/static/components/requirejs/require.js"></script>
        <script>
          requirejs.config({
            paths: {
              base: '/static/base',
              plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',
            },
          });
        </script>
        '''))
  
df = pd.DataFrame({
    'month': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
    'Year_2018': [3.26, 6.11, 4.86, 6.53, 4.45, 3.86, 8.04, 7.59, 1.48, 4.75, 7.27, 11.83],
    'Year_1996': [8.26, 3.82, 6.42, 2.91, 2.12, 1.70, 2.14, 4.66, 4.32, 0.89, 3.22, 4.14]
}
)
df

configure_plotly_browser_state()
for el in list(df_proc_fin.loc[:,:"Tuesday, 28 July 2020 - After 2"].keys()):
  print(f"##### {el} #####")
  df_proc_fin[el] = df_proc_fin[el].astype(float)
  print(f"std:{np.std(df_proc_fin[el].values)},:mean:{np.mean(df_proc_fin[el].values)}")
  ax = sns.distplot(df_proc_fin[el].values,label=el)
plt.legend()
df.iplot(kind='line',x='month',y=['Year_2018', 'Year_1996'], color=['white', 'gold'], 
theme='solar', mode='markers+lines',title='Annual Rainfall in the city Peachtree City, GA')
plt.show()
#PLot the data from df
for el in list(gesamt.keys()):
  print(f"##### {el} #####")
  print(f"std:{np.std(gesamt[el])},:mean:{np.mean(gesamt[el])}")
  ax = sns.distplot(gesamt[el],label=el)
  print(f"##############")
plt.legend()

# ax.axvline(35,c="b", linewidth = 3) #add a line to the graph
plt.show()
# Gustav
### Create the Probability density function
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
import pandas as pd
import seaborn as sns



"""
'#2.Step: Authorize colab to access the spread sheet'
from google.colab import auth
auth.authenticate_user()

import gspread
from oauth2client.client import GoogleCredentials

gc = gspread.authorize(GoogleCredentials.get_application_default())
wb = gc.open_by_url('https://docs.google.com/spreadsheets/d/1wkgMSGum811QOf3awF-cp_5-4vOc7RRBUFnqGpJFBNw/edit?usp=sharing')
'#3.Step: Load the data from the speadsheet'
sheet = wb.worksheet('gustav')
data = sheet.get_all_values()
df = pd.DataFrame(data)
"""
##################
plt.grid(True)
uebungen={"2020-07-26_uebungen":["Ball","Kopf_dehnen"],
         "2020-07-27_uebungen":["Türe_dehnen","Supermann","dog","strecken_couch"]}
#Übungen für morgen: https://westcoastsci.com/general-blog/2018/11/2/hunchback-of-notre-dont-5-easy-exercises-to-correct-thoracic-kyphosis
gesamt={"2020-07--26-before":[13,12.7,12.5,13,12.5,12.5,  12.3,12.1,12.2,12.6,12.6,12.6,0,0,0,0],
        "2020-07-26_after":[12.5,12.6,12.8,12.7,12.6,13.1,12.3,12.3,12.6,12.7,12.3,12.2,0,0,0,0],
        "2020-07-26_after_2":[12.6,12.4,12.7,12.3,12.6,12.5,11.8,12.2,12.5,11.9,12.5,12.5,0,0,0,0],
        "2020-07-27-before":[12, 11.6, 13, 12.5, 12.5, 12.3, 12.8, 12.2,    13.2, 12.3, 12.5, 11.9, 12.5, 12.5, 12.9, 12.3],
        "2020-07-27_after":[12.5, 11.8, 12.5, 11.8, 12.7, 12.4, 12.8, 12.6, 12.6, 12.7, 12.8, 12.6, 12.7, 13,0,0],}


for el in list(gesamt.keys()):
  print(f"##### {el} #####")
  print(f"std:{np.std(gesamt[el])},:mean:{np.mean(gesamt[el])}")
  ax = sns.distplot(gesamt[el],label=el)
  print(f"##############")
plt.legend()

# ax.axvline(35,c="b", linewidth = 3) #add a line to the graph
plt.show()





 
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
import seaborn as sns
mu = 4
variance = 4**0.5
sigma = math.sqrt(variance)
### Create the Probability density function
x = np.linspace(mu - 5*sigma, mu + 5*sigma, 100)
ax = sns.lineplot(x, stats.norm.pdf(x, mu, sigma))
# ax.axvline(35,c="b", linewidth = 3) #add a line to the graph
part = np.arange(,40,1)
ax.fill_between(part,stats.norm.pdf(part, mu, sigma),)
plt.show()
 
### Create the cumulative distribution function
ax = sns.lineplot(x, stats.norm.cdf(x, mu, sigma))
 
ax.fill_between(x, stats.norm.cdf(x, mu, sigma))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1792564113766438, 'fraction_numerical': 0.06382978723404255, 'mean_word_length': 4.721069732566859, 'pattern_counts': {'":': 68, '<': 49, '<?xml version=': 0, '>': 48, 'https://': 8, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '377009', 'license': 'MIT', 'n_tokens_mistral': 10149, 'n_tokens_neox': 9316, 'n_words': 1649, 'path': 'allergy.ipynb', 'repo_name': 'gwillig/data_analyse_friends_allergy', 'size': '22900'}