ipython-notebook

How to hide <matplotlib.lines.Line2D> in IPython notebook

谁说胖子不能爱 提交于 2019-12-17 09:51:07
问题 I am plotting a NumPy array of values, I , using IPython notebook in %matplotlib inline mode with the plot command plt.plot(I,'o') . The resulting output is: <matplotlib.figure.Figure at 0x119e6ead0> Out[159]: [<matplotlib.lines.Line2D at 0x11ac57090>, <matplotlib.lines.Line2D at 0x11ac57310>, <matplotlib.lines.Line2D at 0x11ac57510>, <matplotlib.lines.Line2D at 0x11ac57690>, <matplotlib.lines.Line2D at 0x11ac57810>, <matplotlib.lines.Line2D at 0x11ac57990>, <matplotlib.lines.Line2D at

How to set the matplotlib figure default size in ipython notebook?

三世轮回 提交于 2019-12-17 07:05:40
问题 I use "$ipython notebook --pylab inline" to start the ipython notebook. The display matplotlib figure size is too big for me, and I have to adjust it manually. How to set the default size for the figure displayed in cell? 回答1: I believe the following work in version 0.11 and above. To check the version: $ ipython --version It may be worth adding this information to your question. Solution: You need to find the file ipython_notebook_config.py . Depending on your installation process this

How to set the matplotlib figure default size in ipython notebook?

随声附和 提交于 2019-12-17 07:05:21
问题 I use "$ipython notebook --pylab inline" to start the ipython notebook. The display matplotlib figure size is too big for me, and I have to adjust it manually. How to set the default size for the figure displayed in cell? 回答1: I believe the following work in version 0.11 and above. To check the version: $ ipython --version It may be worth adding this information to your question. Solution: You need to find the file ipython_notebook_config.py . Depending on your installation process this

how to dynamically update a plot in a loop in ipython notebook (within one cell)

若如初见. 提交于 2019-12-17 07:01:20
问题 Environment: Python 2.7, matplotlib 1.3, IPython notebook 1.1, linux, chrome. The code is in one single input cell, using --pylab=inline I want to use IPython notebook and pandas to consume a stream and dynamically update a plot every 5 seconds. When I just use print statement to print the data in text format, it works perfectly fine: the output cell just keeps printing data and adding new rows. But when I try to plot the data (and then update it in a loop), the plot never show up in the

How do you suppress output in IPython Notebook?

雨燕双飞 提交于 2019-12-17 06:31:13
问题 How can output to stdout be suppressed? A semi-colon can be used to supress display of returned objects, for example >>> 1+1 2 >>> 1+1; # No output! However, a function that prints to stdout is not affected by the semi-colon. >>> print('Hello!') Hello! >>> MyFunction() Calculating values... How can the output from print / MyFunction be suppressed? 回答1: Add %%capture as the first line of the cell. eg %%capture print('Hello') MyFunction() This simply discards the output, but the %%capture magic

How to read a .xlsx file using the pandas Library in iPython?

老子叫甜甜 提交于 2019-12-17 06:25:22
问题 I want to read a .xlsx file using the Pandas Library of python and port the data to a postgreSQL table. All I could do up until now is: import pandas as pd data = pd.ExcelFile("*File Name*") Now I know that the step got executed successfully, but I want to know how i can parse the excel file that has been read so that I can understand how the data in the excel maps to the data in the variable data. I learnt that data is a Dataframe object if I'm not wrong. So How do i parse this dataframe

Show DataFrame as table in iPython Notebook

安稳与你 提交于 2019-12-17 01:34:14
问题 I am using iPython notebook. When I do this: df I get a beautiful table with cells. However, if i do this: df1 df2 it doesn't print the first beautiful table. If I try this: print df1 print df2 It prints out the table in a different format that spills columns over and makes the output very tall. Is there a way to force it to print out the beautiful tables for both datasets? 回答1: You'll need to use the HTML() or display() functions from IPython's display module: from IPython.display import

How to hide code from cells in ipython notebook visualized with nbviewer?

末鹿安然 提交于 2019-12-17 00:21:32
问题 I have an ipython/jupyter notebook that I visualize using NBviewer. How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown? 回答1: from IPython.display import HTML HTML('''<script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( document ).ready(code_toggle); </script> <form action="javascript:code

Cannot show the graphs on ipython notebook

一曲冷凌霜 提交于 2019-12-14 03:58:42
问题 I'm playing around ipython notebook and have a question. I was trying to visualize the stock price and the trading volume in a graph. My code is: import datetime import pandas as pd import pandas.io.data from pandas import DataFrame import matplotlib.pyplot as plt from matplotlib import style # skipping some code to get stock prices ax1= plt.subplot(2,1,1) ax1.plot(df.Close,label="sp500") ax1.plot(ma,label='50MA') plt.legend() ax2=plt.subplot(2,1,2, sharex = ax1) ax2.plot(df['H-L'],label='H-L

Ipython notebook : Name error for Imported script function

China☆狼群 提交于 2019-12-14 03:27:03
问题 I have two scripts sources.py and nest.py . They are something like this sources.py import numpy as np from nest import * def make_source(): #rest of the code def detect(): Nest = nest() Nest.fit() if __name__=='main': detect() nest.py import numpy as np from sources import * class nest(object): def _init_(self): self.source = make_source() def fit(self): #rest of the code When I run the script like python sources.py It works fine. But in the Ipython notebook environment if I do the following