ipython-notebook

Jupyter: Programmatically Clear Output from all Cells when Kernel is Ready

孤者浪人 提交于 2021-01-28 04:27:41
问题 I have a question on how to programmatically clear\clean the output from all the Cells in my Jupyter notebook after notebook is done loading (when Kernel is ready), and prior to the user, myself, manually executing code. Basically, I would like the notebook to look clean when it is done loading, and I would like to do it automatically. How can I impose a command like clear_output() from a single initialization cell on to all other cells in the notebook? Thank you. 回答1: For a trusted notebook

URLError with SPARQLWrapper at sparql.query().convert()

和自甴很熟 提交于 2021-01-28 00:21:16
问题 I try a small python script to test my SPARQL request. However, just the next simple code doesn't work. from SPARQLWrapper import SPARQLWrapper, JSON import rdflib #connect to the sparql point sparql = SPARQLWrapper("http://localhost:3030/sparql") #SPARQL request sparql.setQuery(""" PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX

Scientific/Exponential notation with sympy in an ipython notebook

谁都会走 提交于 2021-01-27 23:11:00
问题 How is the threshold for scientific notation set in an ipython notebook? I want to set all number outisde of something like [0.01, 100] to be printed in scientific notation, but the threshold seems to be much higher. i.e. In [165]: x = sympy.Symbol('x'); 1.e8*x Out[165]: 100000000.0*x but In [166]: 1.e28*x Out[166]: 1.0e+28*x Because I'm using sympy, I can't send the number to a formatted print statement, i.e. In [167]: print "%.2e" % (1.e8*x) ERROR: TypeError: float argument required, not

Octave kernel for jupyter not working on windows 10

亡梦爱人 提交于 2021-01-27 12:22:55
问题 I tried to install the octave kernel for jupyter using pip (as suggested here https://github.com/calysto/octave_kernel). But I cannot choose the Octave kernel when creating a new notebook. It worked without problems on my Mac, so I guess it might be a Windows related issue. Does someone have any ideas, how I could fix or investigate the problem? Octave is installed. 回答1: Setting environmental variable OCTAVE_EXECUTABLE to C:\\Octave\\Octave-4.2.1\\bin\\octave-cli.exe and restarting the PC

ipython notebook arrange plots horizontally

旧城冷巷雨未停 提交于 2021-01-20 16:07:55
问题 Currently, when creating two consecutive plots in an ipython notebook, they are displayed one below the other: I'm wondering if there's any way to have them displayed in rows until the space runs out in the window. So for the first two plots, the output would look like this: I realize that I can do something similar by arranging subplots in a grid, but I'm wondering if it's possible to do it automatically so that plots are wrapped onto the next 'line' when the space runs out? 回答1: This works

ipython notebook arrange plots horizontally

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-20 16:07:14
问题 Currently, when creating two consecutive plots in an ipython notebook, they are displayed one below the other: I'm wondering if there's any way to have them displayed in rows until the space runs out in the window. So for the first two plots, the output would look like this: I realize that I can do something similar by arranging subplots in a grid, but I'm wondering if it's possible to do it automatically so that plots are wrapped onto the next 'line' when the space runs out? 回答1: This works

ipython notebook arrange plots horizontally

隐身守侯 提交于 2021-01-20 16:04:40
问题 Currently, when creating two consecutive plots in an ipython notebook, they are displayed one below the other: I'm wondering if there's any way to have them displayed in rows until the space runs out in the window. So for the first two plots, the output would look like this: I realize that I can do something similar by arranging subplots in a grid, but I'm wondering if it's possible to do it automatically so that plots are wrapped onto the next 'line' when the space runs out? 回答1: This works

How to show PIL Image in ipython notebook

谁说胖子不能爱 提交于 2021-01-16 04:39:29
问题 This is my code from PIL import Image pil_im = Image.open('data/empire.jpg') I would like to do some image manipulation on it, and then show it on screen. I am having problem with showing PIL Image in python notebook. I have tried: print pil_im And just pil_im But both just give me: <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=569x800 at 0x10ECA0710> 回答1: You can use IPython's Module: display to load the image. You can read more from the Doc. from IPython.display import Image pil

show origin axis (x,y) in matplotlib plot

你。 提交于 2021-01-13 14:03:46
问题 I have following simple plot, and I would like to display the origin axis (x, y). I already have grid, but I need the x, y axis to be emphasized. this is my code: x = linspace(0.2,10,100) plot(x, 1/x) plot(x, log(x)) axis('equal') grid() I have seen this question. The accepted answer suggests to use "Axis spine" and just links to some example. The example is however too complicated, using subplots. I am unable to figure out, how to use "Axis spine" in my simple example. 回答1: Using subplots is

How to get table column-name/header for SQL query in python

拈花ヽ惹草 提交于 2020-12-31 14:06:17
问题 I have the data in pandas dataframe which I am storing in SQLITE database using Python. When I am trying to query the tables inside it, I am able to get the results but without the column names. Can someone please guide me. sql_query = """Select date(report_date), insertion_order_id, sum(impressions), sum(clicks), (sum(clicks)+0.0)/sum(impressions)*100 as CTR from RawDailySummaries Group By report_date, insertion_order_id Having report_date like '2014-08-12%' """ cursor.execute(sql_query)