ipython-notebook

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

久未见 提交于 2020-12-31 14:04:08
问题 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)

Pretty JSON Formatting in IPython Notebook

六眼飞鱼酱① 提交于 2020-11-30 04:18:47
问题 Is there an existing way to get json.dumps() output to appear as "pretty" formatted JSON inside ipython notebook? 回答1: json.dumps has an indent argument, printing the result should be enough: print(json.dumps(obj, indent=2)) 回答2: This might be slightly different than what OP was asking for, but you can do use IPython.display.JSON to interactively view a JSON/ dict object. from IPython.display import JSON JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}}) Edit: This

Pretty JSON Formatting in IPython Notebook

*爱你&永不变心* 提交于 2020-11-30 04:18:29
问题 Is there an existing way to get json.dumps() output to appear as "pretty" formatted JSON inside ipython notebook? 回答1: json.dumps has an indent argument, printing the result should be enough: print(json.dumps(obj, indent=2)) 回答2: This might be slightly different than what OP was asking for, but you can do use IPython.display.JSON to interactively view a JSON/ dict object. from IPython.display import JSON JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}}) Edit: This

What is the way to set ipython notebook server parameters when running notebook with django-extensions?

心已入冬 提交于 2020-08-24 08:53:40
问题 I am using the following command to run an ipython notebook server with django: ./manage.py shell_plus --notebook The server functions as expected. However, I would like to set the port and not launch a browser when starting the server. If I were running an IPython notebook server without django I successfully use the following: ipython notebook --port=9999 --no-browser I checked the documentation here and tried setting the options using IPYTHON_ARGUMENTS = [ '--ext', 'django_extensions

Export a notebook (.ipynb) as a .py file upon saving

孤人 提交于 2020-08-08 10:46:26
问题 I'm currently working with Jupyter IPython Notebook.I would like to put my notebook under version control. That's why, when I save and checkpoint a Notebook (.ipynb file), I would like the changes to also be saved and synchronized in the corresponding python script (.py file) in the same folder. (see picture below) my_files Does it have something to do with the version of Jupyter I am using? Or do I have to edit a config_file? Thanks 回答1: You need to create jupyter_notebook_config.py in your

How to allow c printf to print in ipython notebook in cython cell?

一世执手 提交于 2020-08-07 05:50:43
问题 %%cython from libc.stdio cimport printf def test(): printf('abc') If I run test() , it doesn't print anything. Currently I am doing something stupid as: cdef char s[80] sprintf(s, 'something') print s What's a better way to use printf in cython? Why doesn't it print? 回答1: You can use the wurlitzer package to capture C-level stdout / stderr and redirect it to IPython. For example, include the following code blocks in your Jupyter notebook: %load_ext Cython %load_ext wurlitzer %%cython from

Draw horizontal lines from x=0 to data points in matplotlib scatterplot (horizontal stem plot)

时间秒杀一切 提交于 2020-06-25 06:04:00
问题 Consider the follwing plot: produced by this function: def timeDiffPlot(dataA, dataB, saveto=None, leg=None): labels = list(dataA["graph"]) figure(figsize=screenMedium) ax = gca() ax.grid(True) xi = range(len(labels)) rtsA = dataA["running"] / 1000.0 # running time in seconds rtsB = dataB["running"] / 1000.0 # running time in seconds rtsDiff = rtsB - rtsA ax.scatter(rtsDiff, xi, color='r', marker='^') ax.scatter ax.set_yticks(range(len(labels))) ax.set_yticklabels(labels) ax.set_xscale('log')