ipython notebook clear cell output in code

You can use IPython.display.clear_output to clear the output of a cell. from IPython.display import clear_output for i in range(10): clear_output(wait=True) print(“Hello World!”) At the end of this loop you will only see one Hello World!. Without a code example it’s not easy to give you working code. Probably buffering the latest n events is a … Read more

collapse cell in jupyter notebook

UPDATE: The newer jupyter-lab is a more modern and feature-rich interface which supports cell folding by default. See @intsco’s answer below UPDATE 2 Since jupyter-lab now also supports extensions, you can extend the built-in cell-folding functionality with the Collapsible_Headings extension. Original answer: The jupyter contrib nbextensions Python package contains a code-folding extension that can be … Read more

Using both Python 2.x and Python 3.x in IPython Notebook

The idea here is to install multiple ipython kernels. Here are instructions for anaconda. If you are not using anaconda, I recently added instructions using pure virtualenvs. Anaconda >= 4.1.0 Since version 4.1.0, anaconda includes a special package nb_conda_kernels that detects conda environments with notebook kernels and automatically registers them. This makes using a new … Read more

Pandas: Setting no. of max rows

Set display.max_rows: pd.set_option(‘display.max_rows’, 500) For older versions of pandas (<=0.11.0) you need to change both display.height and display.max_rows. pd.set_option(‘display.height’, 500) pd.set_option(‘display.max_rows’, 500) See also pd.describe_option(‘display’). You can set an option only temporarily for this one time like this: from IPython.display import display with pd.option_context(‘display.max_rows’, 100, ‘display.max_columns’, 10): display(df) #need display to show the dataframe when … Read more

Show DataFrame as table in iPython Notebook

You’ll need to use the HTML() or display() functions from IPython’s display module: from IPython.display import display, HTML # Assuming that dataframes df1 and df2 are already defined: print “Dataframe 1:” display(df1) print “Dataframe 2:” display(HTML(df2.to_html())) Note that if you just print df1.to_html() you’ll get the raw, unrendered HTML. You can also import from IPython.core.display … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)