-
-
Save izikeros/5996b05214f0c05ab100854bdc7428df to your computer and use it in GitHub Desktop.
[notebook pre-load and pre-config] Script with commands that will be executed upon notebook initialization #notebook #jupyter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
If you often use interactive IPython sessions or Jupyter Notebooks and you’re getting tired of importing the same libraries over and over, try this: | |
Navigate to ~/.ipython/profile_default | |
Create a folder called startup if it’s not already there | |
Add a new Python file called start.py | |
Put your favorite imports in this file | |
Launch IPython or a Jupyter Notebook and your favorite libraries will be automatically loaded every time! | |
author: Will Koehrsen | |
source: https://towardsdatascience.com/how-to-automatically-import-your-favorite-libraries-into-ipython-or-a-jupyter-notebook-9c69d89aa343 | |
""" | |
import pandas as pd | |
import numpy as np | |
# Pandas options | |
pd.options.display.max_columns = 30 | |
pd.options.display.max_rows = 20 | |
from IPython import get_ipython | |
ipython = get_ipython() | |
# If in ipython, load autoreload extension | |
if 'ipython' in globals(): | |
print('\nWelcome to IPython!') | |
ipython.magic('load_ext autoreload') | |
ipython.magic('autoreload 2') | |
# Display all cell outputs in notebook | |
from IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = 'all' | |
# Visualization | |
import plotly.plotly as py | |
import plotly.graph_objs as go | |
from plotly.offline import iplot, init_notebook_mode | |
init_notebook_mode(connected=True) | |
import cufflinks as cf | |
cf.go_offline(connected=True) | |
cf.set_config_file(theme='pearl') | |
print('Your favorite libraries have been loaded.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment