【问题标题】:How can I import two or more packages in jupyter notebook?如何在 jupyter notebook 中导入两个或多个包?
【发布时间】:2021-12-14 01:29:20
【问题描述】:

我想在 jupyter notebook 中用 sn-ps 导入以下包:

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

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

【问题讨论】:

标签: python jupyter-notebook code-snippets jupyter-contrib-nbextensions


【解决方案1】:

包装函数可用于保持清洁。

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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-20
    • 2023-01-23
    • 1970-01-01
    • 1970-01-01
    • 2020-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多