ipython

Run parts of a ipython notebook in a loop / with different input parameter

北城以北 提交于 2020-01-09 10:35:35
问题 I have written a ipython notebook, which analyses a dataset. Now I want to use this code to loop over different datasets. The code is split into about 50 cells (including comments, markdown explanations,...). Is there a way to run parts of a notebook in a loop or running a whole notebook with different input parameters? I don't want to merge all cells into one function or download the code as a python script, as I really like to run (and experimenting with) parts of the analysis by executing

ipython notebook

北战南征 提交于 2020-01-08 03:57:12
参考这个文章,不错 http://blog.csdn.net/kunlong0909/article/details/52464495 1 首先 pip install jupyter2 然后$jupyter notebook --generate-config$vim ~/.jupyter/jupyter_notebook_config.py 进行如下修改: c.NotebookApp.ip='*' c.NotebookApp.password = u'sha:ce...刚才复制的那个密文' c.NotebookApp.open_browser = False c.NotebookApp.port =8888 #随便指定一个端口 3 启动jupyter notebook: $jupyter notebook ipython notebook是一个基于浏览器的Python数据分析工具,使用起来非常方便,具有极强的交互方式和富文本的展示效果。jupyter是它的升级版,它的安装也非常方便,一般Anaconda安装包中会自带。安装好以后直接输入jupyter notebook便可以在浏览器中使用。但是它默认只能在本地访问,如果想把它安装在服务器上,然后在本地远程访问,则需要进行如下配置: 1. 登陆远程服务器 2. 生成配置文件 $jupyter notebook --generate

What to replace loops and nested if sentences with in order to speed up Python code?

瘦欲@ 提交于 2020-01-07 03:16:05
问题 How can I avoid for loops and nested if sentences and be more Pythonic? At first glance this may seem like a "please do my all of my work for me" question. I can assure you that it is not. I'm trying to learn some real Python, and would like to discover ways of speeding up code based on a reproducible example and a pre-defined function. I'm calculating returns from following certain signals in financial markets using loads of for loops and nested if sentences. I have made several attempts,

What to replace loops and nested if sentences with in order to speed up Python code?

岁酱吖の 提交于 2020-01-07 03:15:09
问题 How can I avoid for loops and nested if sentences and be more Pythonic? At first glance this may seem like a "please do my all of my work for me" question. I can assure you that it is not. I'm trying to learn some real Python, and would like to discover ways of speeding up code based on a reproducible example and a pre-defined function. I'm calculating returns from following certain signals in financial markets using loads of for loops and nested if sentences. I have made several attempts,

IPython.parallel - can I write my own log into the engine logs?

拜拜、爱过 提交于 2020-01-07 02:44:08
问题 I'd like to be able to log outputs from the functions I pass to my engines in the relevant engine logs. I.e.: data = /* my list of data to operate on */ def fn(inval): import logging log = logging.getLogger() log.error('This is on the engine') // do stuff return result calculated_data = [] for datum in data: calc = view.apply(fn, datum) calculated_data.append(calc) I'd like to be able to see the log statements in the relevant engine log that operated on the specific task. 回答1: You can grab

How to coroutine IPython <-> a callback()

試著忘記壹切 提交于 2020-01-07 01:26:45
问题 In an IPython terminal, I want a function deep in main() to go back to IPython, where I can print, set ... as usual, then keep running main() : IPython run main.py ... def callback( *args ): ... try: back_to_ipython() # <-- how to do this ? In[]: print, set *args ... ... except KeyboardInterrupt: # or IPython magic pass return # from callback(), keep running main() This must run in python2. (The name callback could be anything , but my use case is scipy.optimize -> callback. Perhaps some

Scrapy not finding table

好久不见. 提交于 2020-01-06 20:04:13
问题 I am trying to scrape data from the table in http://www.oddsportal.com/basketball/usa/nba-2014-2015/results/ The particular table I want has class="table-main" running from scrapy response.xpath('//table') In [28]: response.xpath('//table') Out[28]: [<Selector xpath='//table' data=u'<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t<td c lass="bol'>, <Selector xpath='//table' data=u'<table class="table-main top-event">\n\t\t\t'> , <Selector xpath='//table' data=u'<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t

Find a null value and drop from a dataframe in Pandas

孤街浪徒 提交于 2020-01-06 19:06:26
问题 Hi I have a dataframe like this with 500+ rows. company_url company tag_line product data 0 https://angel.co/billguard BillGuard The fastest smartest way to track your spendin... BillGuard is a personal finance security app t... New York City · Financial Services · Security ... 1 https://angel.co/tradesparq Tradesparq The world's largest social network for global ... Tradesparq is Alibaba.com meets LinkedIn. Trad... Shanghai · B2B · Marketplaces · Big Data · Soc... 2 https://angel.co/sidewalk

IPython notebook put code cells into columns

烂漫一生 提交于 2020-01-06 14:41:45
问题 Is there a way to organize the code cells in a column format? I would like to write derivations in IPython notebook, but every auxiliary equation seems to break up my derivation. I'm using a module to write my equations and entering my equations into code cells, so I can't use simple html alignment inside markdown. Any help is greatly appreciated! An example of what I mean is that I would like my code cells to look like this... Instead of the regular vertically aligned cells... 回答1: After

IPython notebook put code cells into columns

ⅰ亾dé卋堺 提交于 2020-01-06 14:41:14
问题 Is there a way to organize the code cells in a column format? I would like to write derivations in IPython notebook, but every auxiliary equation seems to break up my derivation. I'm using a module to write my equations and entering my equations into code cells, so I can't use simple html alignment inside markdown. Any help is greatly appreciated! An example of what I mean is that I would like my code cells to look like this... Instead of the regular vertically aligned cells... 回答1: After