May-16-2022, 02:27 PM
Hi all,
In Jupyter Notebook I ran these cells:
However, earlier this morning I ran my full 350-line program before pasting the last 55 lines into a separate file. This is the portion of the program responsible for the graphing. I got NameError. First, plt was not defined even though running the full program included "import matplotlib.pyplot as plt". After adding that on top of the separate file, I got btstats---name of the dataframe defined in the full program--not defined. Any ideas as to why these names might not have been retrievable from memory since I had run them previously in this JN session (e.g. I didn't shut down the kernel, close the tab, or otherwise reset JN)?
In Jupyter Notebook I ran these cells:
sample_data = [[3000,18], [3200,17], [3500,16], [4000,12]] sample_df = pd.DataFrame(sample_data, columns = ['SPX', 'Spread_Price'])Next, I ran this as a single cell:
fig, axs = plt.subplots() axs.plot(sample_df['SPX']) axs.twinx() axs.plot(sample_df['Spread_Price']) plt.show()This gave me a graph. Before I get into what's wrong with the graph, I want to point out that it had no problem processing the df still in memory from the cell just ran before. This is how JN usually works and one reason I really like it.
However, earlier this morning I ran my full 350-line program before pasting the last 55 lines into a separate file. This is the portion of the program responsible for the graphing. I got NameError. First, plt was not defined even though running the full program included "import matplotlib.pyplot as plt". After adding that on top of the separate file, I got btstats---name of the dataframe defined in the full program--not defined. Any ideas as to why these names might not have been retrievable from memory since I had run them previously in this JN session (e.g. I didn't shut down the kernel, close the tab, or otherwise reset JN)?