nodes: 0, module; 1, function_definition; 2, function_name:domain_user_stats; 3, parameters; 4, comment:# type: () -> pd.Series; 5, block; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:""" Get number of distinct email addresses in observed domains
  
      TODO: get up to date with new projects layout
      How to build email_domain_users.csv:
  
      from collections import defaultdict
      import logging
      from common import utils as common
      import stscraper as scraper
  
      log = logging.getLogger("domain_user_stats")
      stats = defaultdict(set)
      for ecosystem in common.ECOSYSTEMS:
          urls = common.package_urls(ecosystem)
          for package_name, url in urls.items():
              log.info(package_name)
              try:
                  cs = scraper.commits(url)
              except scraper.RepoDoesNotExist:
                  continue
              for email_addr in cs["author_email"].dropna().unique():
                  if not email_addr or pd.isnull(email_addr):
                      continue
                  try:
                      user, email_domain = clean(email_addr).split("@")
                  except InvalidEmail:
                      continue
                  stats[email_domain].add(user)
      s = pd.Series({dm: len(users) for dm, users in stats.items()})
      s = s.rename("users").sort_values(ascending=False)
      s.to_csv("common/email_domain_users.csv", encoding="utf8", header=True)
      return s
      """; 11, assignment; 12, assignment; 13, subscript; 14, identifier:fname; 15, call; 16, identifier:stats; 17, call; 18, identifier:stats; 19, call; 20, attribute; 21, argument_list; 22, attribute; 23, argument_list; 24, attribute; 25, argument_list; 26, attribute; 27, identifier:join; 28, call; 29, string:"email_domain_users.csv"; 30, identifier:pd; 31, identifier:read_csv; 32, identifier:fname; 33, keyword_argument; 34, keyword_argument; 35, keyword_argument; 36, identifier:pd; 37, identifier:notnull; 38, attribute; 39, identifier:os; 40, identifier:path; 41, attribute; 42, argument_list; 43, identifier:header; 44, integer:0; 45, identifier:squeeze; 46, True; 47, identifier:index_col; 48, integer:0; 49, identifier:stats; 50, identifier:index; 51, attribute; 52, identifier:dirname; 53, identifier:__file__; 54, identifier:os; 55, identifier:path
code: def domain_user_stats():
      # type: () -> pd.Series
      """ Get number of distinct email addresses in observed domains
  
      TODO: get up to date with new projects layout
      How to build email_domain_users.csv:
  
      from collections import defaultdict
      import logging
      from common import utils as common
      import stscraper as scraper
  
      log = logging.getLogger("domain_user_stats")
      stats = defaultdict(set)
      for ecosystem in common.ECOSYSTEMS:
          urls = common.package_urls(ecosystem)
          for package_name, url in urls.items():
              log.info(package_name)
              try:
                  cs = scraper.commits(url)
              except scraper.RepoDoesNotExist:
                  continue
              for email_addr in cs["author_email"].dropna().unique():
                  if not email_addr or pd.isnull(email_addr):
                      continue
                  try:
                      user, email_domain = clean(email_addr).split("@")
                  except InvalidEmail:
                      continue
                  stats[email_domain].add(user)
      s = pd.Series({dm: len(users) for dm, users in stats.items()})
      s = s.rename("users").sort_values(ascending=False)
      s.to_csv("common/email_domain_users.csv", encoding="utf8", header=True)
      return s
      """
      fname = os.path.join(os.path.dirname(__file__), "email_domain_users.csv")
      stats = pd.read_csv(fname, header=0, squeeze=True, index_col=0)
      return stats[pd.notnull(stats.index)]