title: Define few dependable functions inside one. Python
body: <p>For example, Data Frame is:</p>
  
  <pre><code>df = pd.DataFrame(data = {'id': ['393848', '30495'],
                           'text' : ['This is Gabanna. @RT Her human Jose rushed past firefighters into his burning home to rescue her. She suffered burns on her nose and paws, but will be just fine. The family lost everything else. You can help them rebuild below. 14/10 for both (via @KUSINews)',
                                    'Meet Milo. He’s a smiley boy who tore a ligament in his back left zoomer. The surgery to fix it went well, but he’s still at the hospital being monitored. He’s going to work very hard to fetch at full speed again, and you can help him do it below. 13/10']
                           })
  </code></pre>
  
  <p>I wrote some functions:</p>
  
  <pre><code>def tokenize(df): 
      def process_tokens(df): #return column with lists of tokens
          def process_reg(text): #return plain text
              return " ".join([i for i in re.sub(r'[^a-zA-Z\s]', "", str(text)).split()])
          df['tokens'] = [process_reg(text).split() for text in df['text']]
      return process_tokens(df) 
  
  tokenize(df)
  
  def process(df): #return column with dicts
      def process_group(token): #convert list of tokens into dictionery
              return pd.DataFrame(token, columns=["term"]).groupby('term').size().to_dict()
      df['dic'] = [process_group(token) for token in df['tokens']]
  
  process(df)
  </code></pre>
  
  <p>They work great one by one and I got what expected:</p>
  
  <p>I looking for the solution to nest all functions into one to be able to pass data frame just once. </p>
  
  <p>Can't find. </p>
  
  <p>Please, help</p>