I have a Jupyter notebook I am working in. In the first cell, I import several common packages:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
In the next cell I import a package called "apt_pkg", which contains a module named "test_mod.py":
from apt_pkg import *
The module "test_mod.py" contains the following function:
def working():
print('Is working')
print(np.nan)
return
Then I run the function in the Jupyter notebook:
test_mod.working()
When I do this, I get a NameError ("NameError: name 'np' is not defined"). The code can be seen here:
screenshot from Jupyter notebook
If I change the function and reference matplotlib.pyplot as plt (e.g. plt.show()) or pandas as pd (e.g. pd.DataFrame), I also get a NameError where 'plt' or 'pd' is not defined. How can I correct this?