首页 > 解决方案 > 如何在 jupyter notebook 中导入两个或多个包?

问题描述

我想在 jupyter notebook 中导入以下带有片段的包:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import yfinance as yf

我试图在片段中添加我的 sub_menu,但我做不到!谁能给我建议?

标签: pythonjupyter-notebookcode-snippetsjupyter-contrib-nbextensions

解决方案


包装器功能可用于保持清洁。

def import_packages():
    global pd, np    # Make the names pd & np global
    import pandas as pd
    import numpy as np

在主笔记本中:

import utils
utils.import_packages()
utils.pd.DataFrame()

推荐阅读