Rstudio Notebook (rmarkdown) 运行 python:描述未显示 [英] Rstudio Notebook (rmarkdown) running python: describe not shown
问题描述
我正在 Rstudio 笔记本中运行一些 python 块,其中包括读取 csv 文件和打印基本统计信息.我找不到将统计信息 (describe()) 打印为输出的方法.代码如下:
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'))
```
和
```{python, engine.path = '/home/user/anaconda3/bin/python3'}
summary = data_py.describe(include='all')
print(summary)
```
没有成功.有什么帮助吗?
with no success. Any help?
推荐答案
我遇到了同样的问题,如果您将其放入 .Renviron 文件,我发现您编写的代码有效:
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/
PYTHONPATH=/home/alex/anaconda2/lib/python2.7/site-packages/
更改站点包的路径(或包所在的位置)
Change the path to your site-packages (or where packages are)
<代码>{蟒蛇}进口大熊猫data_py = pandas.read_csv('data.csv', sep=';')data_py.describe(include='all')总结 =data_py.describe(include='all')打印(摘要)
这篇关于Rstudio Notebook (rmarkdown) 运行 python:描述未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!