-2

I want to import the following packages with snippets in jupyter notebook:

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

I tried to add my sub_menu in snippets, but I couldn't! Can anyone give me advice?

dasJulian
  • 497
  • 6
  • 21
Reza
  • 35
  • 4

1 Answers1

0

A wrapper function can be used to keep things clean.

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

And in the main notebook:

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