Import
Ways of importing libraries
Import library
import numpy
numpy.array([1, 2, 3])
Import library with alias
import numpy as np
np.array([1, 2, 3])
Import class from library
from sklearn.impute import SimpleImputer
SimpleImputer(args)
Import class from library with alias
from sklearn.impute import SimpleImputer as Imputer
Imputer(args)
Import everything from a library
I do not (almost never) use this. I do not want namespace collisions.
from numpy import *
array([1, 2, 3])
Predefined imports for projects
Standard
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
Plotly
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objects as go
import plotly.express as px
import chart_studio.plotly as py
import cufflinks as cf
import dash_core_components as dcc
import dash_html_components as html
import country_converter as coco
import geopy
from jupyter_dash import JupyterDash
from dash.dependencies import Input, Output
from plotly.offline import init_notebook_mode, download_plotlyjs, plot, iplot
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter
Leave a comment