parameters: ()
return_statement: return n
docstring: Find the first place in the stack that is not inside pandas
      (tests notwithstanding).
docstring_summary: Find the first place in the stack that is not inside pandas
      (tests notwithstanding).
docstring_tokens: Find the first place in the stack that is not inside pandas ( tests notwithstanding ) .
function: def find_stack_level() -> int:
      """
      Find the first place in the stack that is not inside pandas
      (tests notwithstanding).
      """
      stack = inspect.stack()
  
      import pandas as pd
  
      pkg_dir = os.path.dirname(pd.__file__)
      test_dir = os.path.join(pkg_dir, "tests")
  
      for n in range(len(stack)):
          fname = stack[n].filename
          if fname.startswith(pkg_dir) and not fname.startswith(test_dir):
              continue
          else:
              break
      return n
function_tokens: def find_stack_level ( ) -> int : stack = inspect . stack ( ) import pandas as pd pkg_dir = os . path . dirname ( pd . __file__ ) test_dir = os . path . join ( pkg_dir , "tests" ) for n in range ( len ( stack ) ) : fname = stack [ n ] . filename if fname . startswith ( pkg_dir ) and not fname . startswith ( test_dir ) : continue else : break return n