title: Getting the output of a shell command in Jupyter Notebook
body: <p>If I have a python file with the below script:</p>
  
  <pre><code>import pandas as pd
  
  def csv():
  
      r = pd.DataFrame([[1,2,3,6],[1,3,4,5]])
      return r
  
  csv()
  
  </code></pre>
  
  <p>How can I use a shell command in Jupyter Notebook to get the output of this script which is a pandas DataFrame. Or How do I modify the python script to do so but sill use a shell command in Jupyter (For some reason I need a shell command rather than just importing the function from the python file and executing it)</p>
  
  <p>What I tried so far is the following but did not work ( want the Pandas DataFrame as output)</p>
  
  <pre><code>import subprocess
  result = subprocess.run(['python','MyPythonFile.py'], stdout=subprocess.PIPE)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>result = ! python MyPythonFile.py
  </code></pre>