text: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  """
  Created on Thu Dec 17 12:59:29 2020
  
  @author: annaklara
  """
  
  import re
  import numpy as np
  import pandas as pd
  import math 
  # %% Part A
  import re
  def names():
      simple_string = """Amy is 5 years old, and her sister Mary is 2 years old. 
      Ruth and Peter, their parents, have 3 kids."""
  
      pattern = '[A-Z][a-z]*'
      result = re.findall(pattern, simple_string)
      return(result)
      raise NotImplementedError()
  
  assert len(names()) == 4, "There are four names in the simple_string"
  # %% part b
  with open ("/Users/niven/Documents/DataScienceWithPython/I_IntroductionToDataScience/Test.txt", "r") as file:
      data = file.read()
      list_lines = data.splitlines()
      
      list_times=[]
      list_vals=[]
      for line in list_lines:
          line=line.strip()
          if line.startswith('Time'):
              splitline=float(line.split('=')[-1])
              list_times.append(splitline)
          #q = re.findall(pattern_num,line)
          splitline=re.split('\s+',line)
          trim = [i for i in splitline if i.isnumeric()]
          if len(trim) > 0:
              vals = [float(i) for i in splitline]
              list_vals.append(vals[1])
              print(vals)
      #patternGrade = '[B]$|[B][\s]$'
     # patternName = '[\S\s]+(?=[:])'
      #bstudents = []
      #for n in gradeslist:
          #if re.findall(patternGrade, n):
              #name = re.findall(patternName, n)[0]
              #bstudents.append(name)
          
  
  # %% part c
  
  if line.startswith('Time'):
              splitline=float(line.split('=')[-1])
              list_times.append(splitline)
          if line.startswith('\s+'):
              space_lines.append(line)
              
              
  def logs():
      loglist = []
      with open("assets/logdata.txt", "r") as file:
          logdata = file.read()
          loglines = logdata.splitlines()
          
          patternHost = '[\d]+[\.][\d]+[\.][\d]+[.][\d]+'
          patternUser = '(?<=[-][\s])[\S]+'
          patternTime = '(?<=[\[])[\S]+[\s][\S]+(?=[\]])'
          patternRequest = '(?<=["])[\S\s]+(?=["])'
          
          for l in loglines:
              aH = re.findall(patternHost, l)[0]
              aU = re.findall(patternUser, l)[0]
              aT = re.findall(patternTime, l)[0]
              aR = re.findall(patternRequest, l)[0]
              logDict = { 'host':aH, 'user_name':aU, 'time':aT, 'request':aR }
              loglist.append(dict(logDict))
  
          return(loglist)
      # YOUR CODE HERE
      raise NotImplementedError()
  assert len(logs()) == 979
  
  one_item={'host': '146.204.224.152',
    'user_name': 'feest6811',
    'time': '21/Jun/2019:15:45:24 -0700',
    'request': 'POST /incentivize HTTP/1.1'}
  assert one_item in logs(), "Sorry, this item should be in the log results, check your formating"
  
  # %% quiz 1 workspace
  # question 1
  sdata = {'Ohio': 35000, 'Texas': 71000, 'Oregon': 16000, 'Utah': 5000}
  obj1 = pd.Series(sdata)
  states = ['California', 'Ohio', 'Oregon', 'Texas']
  obj2 = pd.Series(sdata, index=states)
  obj3 = pd.isnull(obj2)
  x = obj2['California']
  obj2['California'] != x #nan not a value can't compare
  
  obj3['California']
  obj2['California'] == None 
  
  math.isnan(obj2['California'])
  # %%Question 2
  d = {
      '1': 'Alice',
      '2': 'Bob',
      '3': 'Rita',
      '4': 'Molly',
      '5': 'Ryan'
  }
  S = pd.Series(d)
  check = S.iloc[0:3]
  # %% question 3 recast column headers to capitals
  ss = pd.Series( ['a', 'b', 'c'] , name = 'vals')
  ss.to_frame() # problem, this was still a series
  
  ss = pd.DataFrame({"aaaa": [1, 2, 3], "bbbb": [4, 5, 6]})
  ss.rename(mapper = lambda x: x.upper(), axis = 1, inplace = True)
  ss.rename(mapper = lambda x: x.upper(), axis =1)
  ss = ss.rename(mapper = lambda x: x.upper(), axis = 1)
  ss = ss.rename(mapper = lambda x: x.upper(), axis = 'columns')
  # question 4
  df = pd.DataFrame({"gre score": [1, 2, 3, 3], "toefl score": [4, 105, 107, 1066]})
  df.where(df['toefl score'] > 105)
  df[df['toefl score'] > 105]
  df.where(df['toefl score'] > 105).dropna()
  # question 6
  ss = pd.DataFrame( {'state': ['Ohio', 'Color', 'Utah', 'ny'], 'one': [0, 4, 8, 12], 'two': [1, 5, 9, 13] } )
  ss.set_index('state', inplace=True)
  ss.drop('one', axis=1)
  ss.drop('two')
  ss.drop( ['Utah', 'Color'] )
  ss.drop('Ohio')
  # %% q7
  s1 = pd.Series({1: 'Alice', 2: 'Jack', 3: 'Molly'})
  s2 = pd.Series({'Alice': 1, 'Jack': 2, 'Molly': 3})
  s2[1]
  s2.iloc[1]
  s1.loc[1]
  s2.loc[1]
  # %% q8
  #s1.append(s2)
  for index, value in s1.iteritems():
      print(f"Index: {index}, Value: {value}")
      
  # %% Q9
  df = pd.DataFrame({"gre score": [1, 2, 3, 3], "toefl score": [4, 105, 107, 1066]})
  (df['toefl score'] > 105) & (df['toefl score'] < 115)
  df[ df['toefl score'].gt(105) & df['toefl score'].lt(115) ]
  # %% 10
  ss = pd.DataFrame( {'major': ['Mathematics', 'Soc'], 'Name': ['Alice', 'Jack'], 'Age': [20, 22], 'Gender':['F','M'] } )
  ss.set_index('major', inplace=True)
  ss.T['Mathematics']
  ss['Alice']
  