天道酬勤,学无止境

ipython-notebook

How to include border around cells when using IPython.display of Pandas table in Jupyter Notebook

In Python 3.4, the cells were easy to see because they had a black border around them. In Python 3.5, the this border has been replaced with a more subtle white/grey shading, which makes the cells blend together visually. I want to add a black border like Python 3.4 used to use. Is this possible?

2022-01-17 19:30:31    分类:问答    python   ipython   jupyter-notebook   ipython-notebook   jupyter

How to get Ipython irkernel to plot graphics inline?

Having problems to get an R-script to plot "inline" in Ipython (Jupyter) using the irkernel. The script runs fine but the graphics are displayed in a 'Quartz Windows' instead of inline. How can I change this behavior? Have tried running the same script in Rstudio and get similar but inconsistent behavior. In this case some graphs are displayed within Rstudio while others are displayed in 'Quartz'. Environment is Jupyter latest, irkernel on OSX Yosemite

2022-01-17 11:56:21    分类:问答    r   rstudio   ipython-notebook

使用笔记本时将jar添加到pyspark(Add jar to pyspark when using notebook)

问题 我正在尝试将 mongodb hadoop 与 spark 集成,但无法弄清楚如何使 IPython 笔记本可以访问这些 jar。 这是我想要做的: # set up parameters for reading from MongoDB via Hadoop input format config = {"mongo.input.uri": "mongodb://localhost:27017/db.collection"} inputFormatClassName = "com.mongodb.hadoop.MongoInputFormat" # these values worked but others might as well keyClassName = "org.apache.hadoop.io.Text" valueClassName = "org.apache.hadoop.io.MapWritable" # Do some reading from mongo items = sc.newAPIHadoopRDD(inputFormatClassName, keyClassName, valueClassName, None, None, config) 当我使用以下命令在 pyspark 中启动它时,此代码运行良好: spark-1.4.1/bin

2022-01-16 15:19:41    分类:技术分享    python   jar   apache-spark   ipython-notebook   pyspark

IPython/Jupyter notebook 3 - 默认隐藏标题(IPython/Jupyter notebook 3 - hide headers by default)

问题 在 IPython 笔记本版本 3.0 之前,默认情况下可以通过将其添加到“.ipython\profile_default\static\custom\custom.js”(在 Windows 上)来隐藏笔记本标题: $([IPython.events]).on("app_initialized.NotebookApp", function () { $('div#header').hide(); $('div#maintoolbar').hide(); }); 或者对于 Jupyter,“~/.jupyter/custom/custom.js”,将IPython替换为Jupyter 。 也看到这个问题 这似乎不再起作用了。 它隐藏了标题,但它也在页面的顶部和底部留下了很大的空隙。 我不熟悉javascript和css。 有没有人找到解决这个问题的方法? 回答1 将此添加到您的个人资料中的 custom.css(例如 ~/.ipython/profile_default/static/custom/custom.css 对我来说): div#site{ height: 100% !important; } 删除底部任何令人讨厌的灰色空间。 此外,我将其添加到我的 custom.js (同一文件夹)以使用 ctrl-` 切换标题: $([IPython.events]).on

2022-01-16 15:03:04    分类:技术分享    ipython   customization   ipython-notebook   jupyter   jupyter-notebook

IPython/Jupyter notebook 3 - 默认隐藏标题(IPython/Jupyter notebook 3 - hide headers by default)

问题 在 IPython 笔记本版本 3.0 之前,默认情况下可以通过将其添加到“.ipython\profile_default\static\custom\custom.js”(在 Windows 上)来隐藏笔记本标题: $([IPython.events]).on("app_initialized.NotebookApp", function () { $('div#header').hide(); $('div#maintoolbar').hide(); }); 或者对于 Jupyter,“~/.jupyter/custom/custom.js”,将IPython替换为Jupyter 。 也看到这个问题 这似乎不再起作用了。 它隐藏了标题,但它也在页面的顶部和底部留下了很大的空隙。 我不熟悉javascript和css。 有没有人找到解决这个问题的方法? 回答1 将此添加到您的个人资料中的 custom.css(例如 ~/.ipython/profile_default/static/custom/custom.css 对我来说): div#site{ height: 100% !important; } 删除底部任何令人讨厌的灰色空间。 此外,我将其添加到我的 custom.js (同一文件夹)以使用 ctrl-` 切换标题: $([IPython.events]).on

2022-01-16 15:01:06    分类:技术分享    ipython   customization   ipython-notebook   jupyter   jupyter-notebook

如何让 nbviewer 显示本地文件?(How to make nbviewer display local files?)

问题 我已经安装并工作了 nbviewer。 我看到它有一个带有文件夹名称的--localfiles选项。 它说:“在 /home/gb/S14/inclass 中为本地笔记本提供服务,这可能存在安全风险” 但我无法弄清楚 URL 格式让它在那里寻找文件。 该代码为/localfile/(.*)添加了一个处理程序,但这似乎没有被触发。 任何人都知道如何格式化名称以触发加载本地文件? 回答1 一分钟后,我突然想到,即使服务器支持,首页也可能不支持。 果然, http://localhost:5000/localfile/PythonReference.ipynb?create=1渲染了本地notebook。 回答2 导航到 http://localhost:5000/localfile 将显示一个目录浏览器,从您传递给--localfiles的路径开始; 然后,您只需单击.ipynb文件即可。

2022-01-16 14:16:24    分类:技术分享    ipython-notebook

How to make nbviewer display local files?

I've got nbviewer installed and working. I see it has a --localfiles option that takes a folder name. It says: "Serving local notebooks in /home/gb/S14/inclass, this can be a security risk" But I can't figure out the URL format to get it to look for the file there. The code adds a handler for /localfile/(.*) but that doesn't seem to get triggered. Anyone know how to format name to give to trigger loading a local file?

2022-01-16 12:20:13    分类:问答    ipython-notebook

IPython/Jupyter notebook 3 - hide headers by default

Before IPython notebook version 3.0 the notebook headers could be hidden by default by adding this to ".ipython\profile_default\static\custom\custom.js" (on Windows): $([IPython.events]).on("app_initialized.NotebookApp", function () { $('div#header').hide(); $('div#maintoolbar').hide(); }); or for Jupyter, "~/.jupyter/custom/custom.js", with IPython replaced by Jupyter. also see this question This does not seem to work anymore. It hides the headers, but it also leaves a big gap on the page's top and bottom. I am not familiar with javascript and css. Has anyone found a solution to this yet?

2022-01-16 10:31:16    分类:问答    ipython   customization   ipython-notebook   jupyter   jupyter-notebook

Add jar to pyspark when using notebook

I'm trying the mongodb hadoop integration with spark but can't figure out how to make the jars accessible to an IPython notebook. Here what I'm trying to do: # set up parameters for reading from MongoDB via Hadoop input format config = {"mongo.input.uri": "mongodb://localhost:27017/db.collection"} inputFormatClassName = "com.mongodb.hadoop.MongoInputFormat" # these values worked but others might as well keyClassName = "org.apache.hadoop.io.Text" valueClassName = "org.apache.hadoop.io.MapWritable" # Do some reading from mongo items = sc.newAPIHadoopRDD(inputFormatClassName, keyClassName

2022-01-16 09:01:39    分类:问答    python   jar   apache-spark   ipython-notebook   pyspark

余弦函数的python sympy计算积分错误(error with python sympy computing integral for cosine function)

问题 因此,我直接从 sympy 文档中尝试了一个示例,但遇到了一个奇怪的错误。 我正在使用带有 sympy 0.7.3 的 python 3.2。 我一直在 ipython 笔记本上工作,但我认为这不会有什么不同。 错误是每当我创建一个“x”符号并尝试整合 math.cos(x) 时,我都会收到一条错误消息,提示“无法将表达式转换为浮点数”。 这是一个代码示例。 这取自 sympy 文档。 import sympy import math x = sympy.Symbol('x') sympy.integrate(x**2 * math.exp(x) * math.cos(x), x) 结果的错误消息是: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-123-84e55454fb60> in <module>() ----> 1 sympy.integrate(x**2 * math.exp(x) * math.cos(x), x) /usr/local/lib/python3.2/dist-packages/sympy/core/expr.py in _

2022-01-16 05:04:16    分类:技术分享    python   math   python-3.x   ipython-notebook   sympy