问题
I am runing some python chunks in a Rstudio notebook, which include reading a csv file and printing basic statistics. I could not find the way to print the statistics (describe()) as an output. Here is the code:
```{python, engine.path = '/home/user/anaconda3/bin/python3'}
import pandas
data_py = pandas.read_csv('/home/user/datafiles/data.csv', sep= ';')
```
```{python, engine.path = '/home/user/anaconda3/bin/python3'}
data_py.describe(include='all')
```
NO output printed. I also tried:
```{python, engine.path = '/home/user/anaconda3/bin/python3'}
print(data_py.describe(include='all'))
```
and
```{python, engine.path = '/home/user/anaconda3/bin/python3'}
summary = data_py.describe(include='all')
print(summary)
```
with no success. Any help?
回答1:
I had the same problem and found out the code you wrote works if you put in your .Renviron file:
PYTHONPATH=/home/alex/anaconda2/lib/python2.7/site-packages/
Change the path to your site-packages (or where packages are)
{python} import pandas data_py = pandas.read_csv('data.csv', sep= ';') data_py.describe(include='all') summary = data_py.describe(include='all') print( summary)
来源:https://stackoverflow.com/questions/40512587/rstudio-notebook-rmarkdown-running-python-describe-not-shown