Rstudio Notebook (rmarkdown) running python: describe not shown

匿名 (未验证) 提交于 2019-12-03 01:12:01

问题:

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)



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!