{"id":184295,"date":"2023-01-26T15:07:00","date_gmt":"2023-01-26T20:07:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/traders-insight\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/"},"modified":"2023-02-09T15:57:00","modified_gmt":"2023-02-09T20:57:00","slug":"python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/","title":{"rendered":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file. It will avoid occasional mistakes and save time to write redundant common codes such as importing library, declaring user-defined functions, data and its preprocessing, to name a few.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To import an ipynb file in another ipynb file, we need to install&nbsp;<strong>import-ipynb<\/strong>&nbsp;python package which is apapted exactly to our purpose.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install import-ipynb library from the command prompt\n!pip install import-ipynb\n\nImport it from your notebook\nimport import_ipynb\n\nImport your BBB.ipynb notebook as if it was BBB.py file\nfrom BBB import *<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Sample code as a whole : a_simple_rnn.ipynb<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A sample code is a deep learning model using the SimpleRNN model which consists of including package libraries, loading and preprocessing data, setting up model, fitting and prediction. This is a whole file which will be divided into two files in the next.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Import and Install Library\n \n# In&#91;1]:\n_________________________________________________________________\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom keras.models import Sequential\nfrom keras.layers import Dense, SimpleRNN\nget_ipython().run_line_magic('matplotlib', 'inline')\nfrom IPython.core.interactiveshell import InteractiveShell\nInteractiveShell.ast_node_interactivity = \"all\"\n_________________________________________________________________\n \n# ## Functions\n# In&#91;2]:\n_________________________________________________________________\n# convert into dataset matrix\ndef convertToMatrix(data, step):\n    X, Y =&#91;], &#91;]\n    for i in range(len(data)-step):\n        d=i+step; X.append(data&#91;i:d,]); Y.append(data&#91;d,])\n    return np.array(X), np.array(Y)\n \ndef draw_plot1(df,predicted):\n    index = df.index.values\n    plt.figure(figsize=(5, 2.5))\n    plt.plot(index,df); plt.plot(index,predicted)\n    plt.show()\n    return plt\n_________________________________________________________________\n \n# ## Load Dataset\n# In&#91;3]:\n_________________________________________________________________\nstep = 4; N = 1000; Tp = 800    \nt=np.arange(0,N)\nx=np.sin(0.02*t)+2*np.random.rand(N)\ndf = pd.DataFrame(x)\n# df.head(); plt.plot(df); plt.show()\ntrain=df.values\ntrain = np.append(train,np.repeat(train&#91;-1,],step))\ntrainX,trainY = convertToMatrix(train,step)\ntrainX = np.reshape(trainX, (trainX.shape&#91;0], 1, trainX.shape&#91;1]))\n_________________________________________________________________\n \n# ## Building Model\n# In&#91;4]:\n_________________________________________________________________\nmodel = Sequential()\nmodel.add(SimpleRNN(units=32, input_shape=(1,step), activation=\"relu\"))\nmodel.add(Dense(8, activation=\"relu\")) \nmodel.add(Dense(1))\nmodel.compile(loss='mean_squared_error', optimizer='rmsprop')\nmodel.summary()\n_________________________________________________________________\nModel: \"sequential\"\n_________________________________________________________________\n Layer (type)                Output Shape              Param #   \n=================================================================\n simple_rnn (SimpleRNN)      (None, 32)                1184      \n                                                                 \n dense (Dense)               (None, 8)                 264       \n                                                                 \n dense_1 (Dense)             (None, 1)                 9         \n                                                                 \n=================================================================\nTotal params: 1,457\nTrainable params: 1,457\nNon-trainable params: 0\n_________________________________________________________________\n \n# ## Training Model\n# In&#91;5]:\n_________________________________________________________________\nmodel.fit(trainX, trainY, epochs=100, batch_size=16, verbose=0)\n_________________________________________________________________\n \n# In&#91;6]:\n_________________________________________________________________\ntrainPredict = model.predict(trainX)\ntrainScore = model.evaluate(trainX, trainY, verbose=0)\nprint(trainScore)\ndraw_plot1(df,trainPredict)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">1) Common code block : a0_load_lib_data_func.ipynb<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following python code in the Jupyter notebook (<strong>a0_load_lib_data_func.ipynb<\/strong>) contains package libraries, some user-defined functions, and data. This file will be imported in each mode files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Import and Install Library\n \n# In&#91;1]:\n_________________________________________________________________\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom keras.models import Sequential\nfrom keras.layers import Dense, SimpleRNN\nget_ipython().run_line_magic('matplotlib', 'inline')\nfrom IPython.core.interactiveshell import InteractiveShell\nInteractiveShell.ast_node_interactivity = \"all\"\n_________________________________________________________________\n \n# ## Functions\n# In&#91;2]:\n_________________________________________________________________\n# convert into dataset matrix\ndef convertToMatrix(data, step):\n    X, Y =&#91;], &#91;]\n    for i in range(len(data)-step):\n        d=i+step; X.append(data&#91;i:d,]); Y.append(data&#91;d,])\n    return np.array(X), np.array(Y)\n \ndef draw_plot1(df,predicted):\n    index = df.index.values\n    plt.figure(figsize=(5, 2.5))\n    plt.plot(index,df); plt.plot(index,predicted)\n    plt.show()\n    return plt\n_________________________________________________________________\n \n# ## Load Dataset\n# In&#91;3]:\n_________________________________________________________________\nstep = 4; N = 1000; Tp = 800    \nt=np.arange(0,N)\nx=np.sin(0.02*t)+2*np.random.rand(N)\ndf = pd.DataFrame(x)\n# df.head(); plt.plot(df); plt.show()\ntrain=df.values\ntrain = np.append(train,np.repeat(train&#91;-1,],step))\ntrainX,trainY = convertToMatrix(train,step)\ntrainX = np.reshape(trainX, (trainX.shape&#91;0], 1, trainX.shape&#91;1]))<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2) Each model-specific file : a1_simple_rnn_wo_lib_data_func.ipynb<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following python code (<strong>a1_simple_rnn_wo_lib_data_func.ipynb<\/strong>) imports another Jupyter Notebook file (<strong>a0_load_lib_data_func.ipynb<\/strong>). As the imported file contains common code blocks, this file does not contain these redundant information but has the content of each specific model and routines for forecasting performance comparisons.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Import a0_read_lib_data_func.ipynb file\n# In&#91;1]:\n_________________________________________________________________\n# install if not installed\n#!pip install import-ipynb\n \n# import it from your notebook\nimport import_ipynb\n \n# import a0_load_lib_data_func notebook\nfrom a0_load_lib_data_func import *\n_________________________________________________________________\n \n# ## Building Model\n# In&#91;4]:\n_________________________________________________________________\nmodel = Sequential()\nmodel.add(SimpleRNN(units=32, input_shape=(1,step), activation=\"relu\"))\nmodel.add(Dense(8, activation=\"relu\")) \nmodel.add(Dense(1))\nmodel.compile(loss='mean_squared_error', optimizer='rmsprop')\nmodel.summary()\n_________________________________________________________________\nModel: \"sequential\"\n-----------------------------------------------------------------\n Layer (type)                Output Shape              Param #   \n=================================================================\n simple_rnn (SimpleRNN)      (None, 32)                1184      \n                                                                 \n dense (Dense)               (None, 8)                 264       \n                                                                 \n dense_1 (Dense)             (None, 1)                 9         \n                                                                 \n=================================================================\nTotal params: 1,457\nTrainable params: 1,457\nNon-trainable params: 0\n-----------------------------------------------------------------\n# ## Training Model\n# In&#91;5]:\n_________________________________________________________________\nmodel.fit(trainX, trainY, epochs=100, batch_size=16, verbose=0)\n_________________________________________________________________\n&lt;keras.callbacks.History at 0x22e182f8c70&gt;\n# In&#91;6]:\n_________________________________________________________________\ntrainPredict = model.predict(trainX)\ntrainScore = model.evaluate(trainX, trainY, verbose=0)\nprint(trainScore)\ndraw_plot1(df,trainPredict)\n_________________________________________________________________\n0.3513454794883728<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Concluding Remarks<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This post shows how to use the common code block file which is imported in another model-specific file in Jupyter notebook. Running one file as a whole and running two sparate files deliver the same output. But the latter will be useful since it can avoid redundant copy-and-paste works.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Visit SH Fintech Modeling for additional insight on this topic: <a href=\"https:\/\/kiandlee.blogspot.com\/2023\/01\/python-importing-ipynb-file-jupyter.html\">https:\/\/kiandlee.blogspot.com\/2023\/01\/python-importing-ipynb-file-jupyter.html<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.<\/p>\n","protected":false},"author":662,"featured_media":184296,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,349,338,350,341,344],"tags":[2105,1006,14512,6614,827,4659,1225,1224,14513,14514],"contributors-categories":[13728],"class_list":["post-184295","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-python-development","category-ibkr-quant-news","category-quant-asia-pacific","category-quant-development","category-quant-regions","tag-deep-learning","tag-fintech","tag-ipynb","tag-jupyter-notebook","tag-keras","tag-matplotlib","tag-numpy","tag-pandas","tag-python-data-science","tag-simplernn-model","contributors-categories-sh-fintech-modeling"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v28.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File<\/title>\n<meta name=\"description\" content=\"This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/184295\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File\" \/>\n<meta property=\"og:description\" content=\"This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-26T20:07:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-09T20:57:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sang-Heon Lee\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sang-Heon Lee\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Sang-Heon Lee\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/0a959ff9de7f0465a07baa1fe1ae0200\"\n\t            },\n\t            \"headline\": \"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File\",\n\t            \"datePublished\": \"2023-01-26T20:07:00+00:00\",\n\t            \"dateModified\": \"2023-02-09T20:57:00+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/\"\n\t            },\n\t            \"wordCount\": 303,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/python-notebook.jpg\",\n\t            \"keywords\": [\n\t                \"Deep Learning\",\n\t                \"fintech\",\n\t                \"ipynb\",\n\t                \"Jupyter Notebook\",\n\t                \"Keras\",\n\t                \"Matplotlib\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Python Data Science\",\n\t                \"SimpleRNN model\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Asia Pacific\",\n\t                \"Quant Development\",\n\t                \"Quant Regions\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/\",\n\t            \"name\": \"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/python-notebook.jpg\",\n\t            \"datePublished\": \"2023-01-26T20:07:00+00:00\",\n\t            \"dateModified\": \"2023-02-09T20:57:00+00:00\",\n\t            \"description\": \"This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/python-notebook.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/python-notebook.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/0a959ff9de7f0465a07baa1fe1ae0200\",\n\t            \"name\": \"Sang-Heon Lee\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/sang-heonlee\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File","description":"This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/184295\/","og_locale":"en_US","og_type":"article","og_title":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File","og_description":"This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/","og_site_name":"IBKR Campus US","article_published_time":"2023-01-26T20:07:00+00:00","article_modified_time":"2023-02-09T20:57:00+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg","type":"image\/jpeg"}],"author":"Sang-Heon Lee","twitter_card":"summary_large_image","twitter_title":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File","twitter_misc":{"Written by":"Sang-Heon Lee","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/"},"author":{"name":"Sang-Heon Lee","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200"},"headline":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File","datePublished":"2023-01-26T20:07:00+00:00","dateModified":"2023-02-09T20:57:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/"},"wordCount":303,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg","keywords":["Deep Learning","fintech","ipynb","Jupyter Notebook","Keras","Matplotlib","NumPy","Pandas","Python Data Science","SimpleRNN model"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Asia Pacific","Quant Development","Quant Regions"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/","name":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg","datePublished":"2023-01-26T20:07:00+00:00","dateModified":"2023-02-09T20:57:00+00:00","description":"This post shows how to import a Jupyter Notebook (ipynb) file from another Jupyter Notebook file.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-importing-an-ipynb-file-jupyter-notebook-from-another-ipynb-file\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg","width":1000,"height":563,"caption":"Python: Importing an ipynb File (Jupyter Notebook) from Another ipynb File"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200","name":"Sang-Heon Lee","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/sang-heonlee\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/python-notebook.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/184295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/662"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=184295"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/184295\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/184296"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=184295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=184295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=184295"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=184295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}