{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Dario Radečić",
  "title_listed": "np.stack() - How To Stack two Arrays in Numpy And Python",
  "keywords": "NumPy,数组",
  "domain": "数据处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/np-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a/",
  "publish_date": "2023-01",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "2cf1c9dd7522",
  "collected_at": "2026-10-01T21:28:24",
  "title": "np.stack() - How To Stack two Arrays in Numpy And Python | Towards Data Science",
  "body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# np.stack() - How To Stack two Arrays in Numpy And Python\nBeginner and advanced examples of Stacking in Numpy - Learn how to join a sequence of arrays easily.\n[Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\nJanuary 10, 20236 min read\n### **Beginner and advanced examples of Stacking in Numpy - Learn how to join a sequence of arrays easily**\n![Photo by Brigitte Tohm on Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/0Uy0g3t3S6kF4sESf-scaled.jpg)\nPhoto by [Brigitte Tohm](https://unsplash.com/@brigittetohm?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\nNumpy is an amazing library for data science and machine learning, so there's no way around it if you want to become a data professional. Mastering the ins and outs of the package is mandatory because there's no point in reinventing the wheel - pretty much anything you can think of has already been implemented.\nToday you'll learn all about np stack - or the Numpy's `stack()` function. Put simply, it allows you to join arrays row-wise (default) or column-wise, depending on the parameter values you specify. We'll go over the fundamentals and the function signature, and then jump into examples in Python.\n* * *\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Computer Science](https://roadmap.sh/computer-science) roadmaps.\n## What is np stack?\nNumpy's np stack function is used to stack/join arrays along a new axis. It will return a single array as a result of stacking multiple sequences with the same shape. You can stack multidimensional arrays as well, and you'll learn how shortly.\nBut first, let's explain the difference between horizontal and vertical stacking.\n### Horizontal vs. vertical stack in Numpy\nStacking arrays horizontally means that you take arrays of the same dimensions and stack them on top of each other. Each _input_ array will be a row in the resulting array.\nTake a look at the following image for a better understanding:\n![Image 1 - Horizontal stacking explained \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1v9UND7IoVZlSSwjl_klh2Q.jpeg)\nImage 1 - Horizontal stacking explained (image by author)\nVertical stacking works just the opposite. One row of two vertically stacked arrays contains corresponding elements from both.\nFor example, the first row of a vertically stacked array Z will contain the first elements of the input arrays X and Y.\nMaybe you'll find it easier to grasp visually:\n![Image 2 - Vertical stacking explained \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1xEF4wFJEmRJD9L-159-XhA.jpeg)\nImage 2 - Vertical stacking explained (image by author)\nAnd with that out the way, let's go over the np stack function signature.\n### Function parameters explained\nThe np stack function can take up to three parameters, of which only the first one is mandatory:\n  * `arrays` - sequence of arrays, or array of arrays you want to stack\n  * `axis` - integer, the axis along which you want to stack the arrays (0 = row-wise stacking, 1 = column-wise stacking for 1D arrays, or use -1 to use the last axis)\n  * `out` - optional destination to place the results. If provided, the output array shape must match the stacking result shape\n\n\nEnough theory! Let's now go over some practical examples.\n## Numpy Stack in Action - Function Examples\nWe've talked a lot about horizontal and vertical stacking, so let's see how it works in practice.\n### Numpy horizontal stacking (row-wise)\nTo stack two numpy arrays horizontally, you just need to call the np.stack function and pass in the arrays. No other parameters are required:\npython\n\n```\nimport numpy as np\n\narr1 = np.array([1, 2, 3, 4])\narr2 = np.array([5, 6, 7, 8])\n\n# Horizontal (row-wise) stacking #1\narr_stacked = np.stack([arr1, arr2])\nprint('Numpy horizontal stacking method #1')\nprint('-----------------------------------')\nprint(arr_stacked)\n```\n\nHere's the resulting output:\n![Image 3 - Horizontal stacking in Numpy \\(1\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1PMEOBzHi8RJAACWPzsxYBw.png)\nImage 3 - Horizontal stacking in Numpy (1) (image by author)\nAs you can see, the output looks a lot like a Numpy version of a Pandas DataFrame, which means one array pretty much equals one row of the matrix.\nTo be more explicit, you can achieve the same results by writing `axis=0` as the second parameter:\nphp\n\n```\nimport numpy as np\n\narr1 = np.array([1, 2, 3, 4])\narr2 = np.array([5, 6, 7, 8])\n\n# Horizontal (row-wise) stacking #2\narr_stacked = np.stack([arr1, arr2], axis=0)\nprint('Numpy horizontal stacking method #2')\nprint('-----------------------------------')\nprint(arr_stacked)\n```\n\nThe results are identical:\n![Image 4 - Horizontal stacking in Numpy \\(2\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1i2G0Ewl50hYgHpXr-vSVnA.png)\nImage 4 - Horizontal stacking in Numpy (2) (image by author)\nNext, let's explore vertical stacking.\n### Numpy vertical stacking (column-wise)\nTo stack two numpy arrays vertically, just change the value of the `axis` parameter to 1:\npython\n\n```\nimport numpy as np\n\narr1 = np.array([1, 2, 3, 4])\narr2 = np.array([5, 6, 7, 8])\n\n# Vertical (column-wise) stacking #1\narr_stacked = np.stack([arr1, arr2], axis=1)\nprint('Numpy vertical stacking method #1')\nprint('---------------------------------')\nprint(arr_stacked)\n```\n\nNow the arrays are stacked as columns, meaning you'll have as many columns as you have provided arrays:\n![Image 5 - Vertical stacking in Numpy \\(1\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1R1zCriBaaqCzkA_slq0pJQ.png)\nImage 5 - Vertical stacking in Numpy (1) (image by author)\nWith simple 1D arrays, you can also set `axis=-1` to stack the arrays vertically:\npython\n\n```\nimport numpy as np\n\narr1 = np.array([1, 2, 3, 4])\narr2 = np.array([5, 6, 7, 8])\n\n# Vertical (column-wise) stacking #2\narr_stacked = np.stack([arr1, arr2], axis=-1)\nprint('Numpy vertical stacking method #2')\nprint('---------------------------------')\nprint(arr_stacked)\n```\n\nThe results are identical:\n![Image 6 - Vertical stacking in Numpy \\(2\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/154LPcfWT93EG8tYLindzEg.png)\nImage 6 - Vertical stacking in Numpy (2) (image by author)\nNext, let's discuss some more on stacking N-dimensional arrays.\n### Join 1D arrays with stack()\nYou've already seen how to stack 1-dimensional arrays, but here's a recap:\npython\n\n```\nimport numpy as np\n\narr1 = np.array([1, 2, 3, 4])\narr2 = np.array([5, 6, 7, 8])\n\n# Stacking 1D arrays\narr_stacked = np.stack([arr1, arr2])\nprint('Numpy stacking 1D arrays')\nprint('------------------------')\nprint(arr_stacked)\n```\n\nAnd the output:\n![Image 7 - Stacking 1D arrays \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1U-Y1SPb_uHqCcBpe9e2KNg.png)\nImage 7 - Stacking 1D arrays (image by author)\nRemember that you can change the value of the `axis` parameter if you want to stack the arrays column-wise.\n### Join 2D arrays with stack()\nThe procedure is identical for stacking 2D arrays with np stack. Here's an example:\nphp\n\n```\nimport numpy as np\n\narr1 = np.array([\n    [1, 2, 3, 4],\n    [5, 6, 7, 8]\n])\narr2 = np.array([\n    [9, 10, 11, 12],\n    [13, 14, 15, 16]\n])\n\n# Stacking 2D arrays #1\narr_stacked = np.stack([arr1, arr2])\nprint('Numpy stacking 2D arrays method #1')\nprint('----------------------------------')\nprint(arr_stacked)\n```\n\nWe now get a 3-dimensional array back, each element being a 2-dimensional array of two horizontally stacked arrays:\n![Image 8 - Stacking 2D arrays \\(1\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1aRTvbOvtARP12Bfo5p-Lxg.png)\nImage 8 - Stacking 2D arrays (1) (image by author)\nAs per usual, you can stack 2-dimensional arrays vertically:\npython\n\n```\nimport numpy as np\n\narr1 = np.array([\n    [1, 2, 3, 4],\n    [5, 6, 7, 8]\n])\narr2 = np.array([\n    [9, 10, 11, 12],\n    [13, 14, 15, 16]\n])\n\n# Stacking 2D arrays #2\narr_stacked = np.stack([arr1, arr2], axis=1)\nprint('Numpy stacking 2D arrays method #2')\nprint('----------------------------------')\nprint(arr_stacked)\n```\n\nHere's the output:\n![Image 9 - Stacking 2D arrays \\(2\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1SLWHJUZTUEikCh3EiL1XRg.png)\nImage 9 - Stacking 2D arrays (2) (image by author)\nThat's pretty much all there is to numpy stacking, at least for the basics. Up next, we'll go over some advanced usage examples and frequently asked questions.\n## Advanced: np stack in a loop\nOne of the commonly asked questions is how can you use np stack in a loop. Here's an example - it will first combine two 2-dimensional arrays into a 3-dimensional one:\npython\n\n```\nimport numpy as np\n\narr1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])\narr2 = np.array([[13, 14, 15], [16, 17, 18]])\nmatrix = [arr1, arr2]\n\nprint('Numpy stacking in a loop - intermediary matrix')\nprint('----------------------------------------------')\nprint(matrix)\n```\n\nThis is the intermediary output:\n![Image 10 - Numpy stacking in a loop \\(1\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/10Ks_3zNo07hdGDixOqX3GA.png)\nImage 10 - Numpy stacking in a loop (1) (image by author)\nAnd now to produce a single 2-dimensional array with the elements stacked horizontally, you can use a loop:\npython\n\n```\narr3 = np.empty(shape=[0, matrix[0].shape[1]])\n\nfor m in matrix:\n    arr3 = np.append(arr3, m, axis=0)\n\nprint('Numpy stacking in a loop')\nprint('------------------------')\nprint(arr3)\n```\n\nHere's the result:\n![Image 11 - Numpy stacking in a loop \\(2\\) \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1ENIGf0Ul-5hsZfhe6OgQlA.png)\nImage 11 - Numpy stacking in a loop (2) (image by author)\nWe'll now cover some frequently asked questions about the np stack function in Python.\n* * *\n## FAQ\n### What is the difference between stack and concatenate?\nPut simply, np stack function will return a 2D array when two 1D arrays are passed in. The np concatenate function takes elements of all input arrays and returns them as a single 1D array.\n### What is numpy dstack?\nThe numpy dstack function allows you to combine arrays index by index and store the results like a stack. Here's an example:\nphp\n\n```\nimport numpy as np\n\narr1 = np.array([1, 2, 3, 4])\narr2 = np.array([5, 6, 7, 8])\n\n# Numpy depth stacking - dstack\narr_stacked = np.dstack([arr1, arr2])\nprint('Numpy depth stacking')\nprint('--------------------')\nprint(arr_stacked)\nprint()\nprint(f'Shape = {arr_stacked.shape}')\n```\n\nAnd the output:\n![Image 12 - Numpy dstack \\(image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/131wI-8YVec9xXEDez-zuzQ.png)\nImage 12 - Numpy dstack (image by author)\nSo, we had two 1x4 arrays coming in, and `dstack` combined them vertically into a 3-dimensional array format. Neat for some use cases.\n* * *\n_Loved the article? Become a_[ _Medium member_](https://towardsdatascience.com/@radecicdario/membership) _to continue learning without limits. I'll receive a portion of your membership fee if you use the following link, with no extra cost to you._\n<https://medium.com/@radecicdario/membership>\n* * *\n_Originally published at_[ _https://betterdatascience.com_](https://betterdatascience.com/np-stack/) _on January 10, 2023._\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657095692_93hujy.png)\nWritten By\n## [Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\nhttps://writingfordevs.substack.com\n[See all from Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\n[Data Science](https://towardsdatascience.com/tag/data-science/)[Numpy](https://towardsdatascience.com/tag/numpy/)[Programming](https://towardsdatascience.com/tag/programming/)[Python](https://towardsdatascience.com/tag/python/)[Towards Data Science](https://towardsdatascience.com/tag/towards-data-science/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fnp-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a%2F&title=np.stack\\(\\)%20-%20How%20To%20Stack%20two%20Arrays%20in%20Numpy%20And%20Python)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fnp-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a%2F&title=np.stack\\(\\)%20-%20How%20To%20Stack%20two%20Arrays%20in%20Numpy%20And%20Python)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fnp-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a%2F&text=np.stack\\(\\)%20-%20How%20To%20Stack%20two%20Arrays%20in%20Numpy%20And%20Python)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2019/12/0U9OgNJDKYR07MrJR.jpg)](https://towardsdatascience.com/images-as-data-structures-art-through-256-integers-8898bce17230/)\n## [Images as data structures: art through 256 integers](https://towardsdatascience.com/images-as-data-structures-art-through-256-integers-8898bce17230/)\n[](https://towardsdatascience.com/np-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a/)\nLet's cover the basics of images as data structures, meet some psychedelic cats and 'paint' a hot pink chessboard using NumPy!\n[Justin](https://towardsdatascience.com/author/eustin.jvans/)\nDecember 14, 201914 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/Experiments-illustrated-.jpg)](https://towardsdatascience.com/experiments-illustrated-can-1-change-behavior-more-than-100/)\n## [Can $1 Change Behavior More Than $100?](https://towardsdatascience.com/experiments-illustrated-can-1-change-behavior-more-than-100/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nA small prize for something easy vs a big prize for something difficult\n[Ben Tengelsen](https://towardsdatascience.com/author/btengels/)\nMarch 11, 20257 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/12/1rhV3URvLEWEfBWu4S07vCw-scaled.jpeg)](https://towardsdatascience.com/understanding-convolutional-neural-networks-cnns-81dffc813a69/)\n## [Understanding Convolutional Neural Networks (CNNs)](https://towardsdatascience.com/understanding-convolutional-neural-networks-cnns-81dffc813a69/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA gentle introduction to one of the most powerful deep learning tools and its building blocks\n[Vinicius Trevisan](https://towardsdatascience.com/author/vinicius_trevisan/)\nDecember 30, 20219 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/1ArtYxGFlH3V4gis2MEXJCg.jpeg)](https://towardsdatascience.com/anticipating-wildfires-with-machine-learning-tools-5eb43b450d36/)\n## [Anticipating Wildfires with Machine Learning Tools](https://towardsdatascience.com/anticipating-wildfires-with-machine-learning-tools-5eb43b450d36/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUsing data to uncover ideal wildfire suppression resource placement\n[Patrick Norman](https://towardsdatascience.com/author/patrickisnorman/)\nJune 9, 20215 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/11/0Tt0oeVC1bCnU9fY6.png)](https://towardsdatascience.com/python-and-the-module-search-path-e71ae7a7e65f/)\n## [Python and the Module Search Path](https://towardsdatascience.com/python-and-the-module-search-path-e71ae7a7e65f/)\n[Programming](https://towardsdatascience.com/category/programming/)\nHow python knows which packages to import, where to find them and how modern tools...\n[Mark Jamison](https://towardsdatascience.com/author/markjamison03/)\nNovember 5, 20218 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/057utp1tadb4iYMDS-scaled.jpg)](https://towardsdatascience.com/using-the-missingno-python-library-to-identify-and-visualise-missing-data-prior-to-machine-learning-34c8c5b5f009/)\n## [Using the missingno Python library to Identify and Visualise Missing Data Prior to Machine Learning](https://towardsdatascience.com/using-the-missingno-python-library-to-identify-and-visualise-missing-data-prior-to-machine-learning-34c8c5b5f009/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAn example using petrophysical well log measurements\n[Andy McDonald](https://towardsdatascience.com/author/andymcdonaldgeo/)\nJune 9, 20218 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/0WR69GyoGUavsSV2v-scaled.jpg)](https://towardsdatascience.com/diagnosing-pneumonia-from-x-ray-images-using-convolutional-neural-network-fe9975cab808/)\n## [Diagnosing Pneumonia from X-Ray Images Using Convolutional Neural Network](https://towardsdatascience.com/diagnosing-pneumonia-from-x-ray-images-using-convolutional-neural-network-fe9975cab808/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nApplying image classification technique in medical diagnosis\n[Tony Tsoi](https://towardsdatascience.com/author/tsoiyingkit/)\nApril 4, 20229 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/02/1f6ct2Al6c9vkvVNn93zEWg.png)](https://towardsdatascience.com/airflow-internals-851f4a440028/)\n## [Beneath the Surface: A Closer Look at 4 Airflow Internals](https://towardsdatascience.com/airflow-internals-851f4a440028/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nFour Apache Airflow internals you might have missed\n[Giorgos Myrianthous](https://towardsdatascience.com/author/gmyrianthous/)\nFebruary 3, 20246 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/1MkXejtNAt5HN2f6RgKk6Iw.png)](https://towardsdatascience.com/graphs-gradients-and-groupby-what-my-first-major-project-has-taught-me-a3c96561700a/)\n## [Graphs, Gradients, and Groupby](https://towardsdatascience.com/graphs-gradients-and-groupby-what-my-first-major-project-has-taught-me-a3c96561700a/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhat my first major Data Science project has taught me.\n[Diane Tunnicliffe](https://towardsdatascience.com/author/diane-tunnicliffe/)\nOctober 15, 202012 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "np.stack() - How To Stack two Arrays in Numpy And Python | Towards Data Science",
    "description": "Beginner and advanced examples of Stacking in Numpy - Learn how to join a sequence of arrays easily.",
    "keywords": null,
    "author": "Dario Radečić",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "np.stack() - How To Stack two Arrays in Numpy And Python",
    "og:description": "Beginner and advanced examples of Stacking in Numpy - Learn how to join a sequence of arrays easily.",
    "og:url": "https://towardsdatascience.com/np-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/0Uy0g3t3S6kF4sESf-scaled.jpg",
    "og:image:width": "1920",
    "og:image:height": "2560",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Dario Radečić",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "6 min read",
    "article:published_time": "2023-01-10T14:00:08.000Z",
    "article:modified_time": "2023-01-10T14:00:08.000Z",
    "article:author": "https://towardsdatascience.com/author/radecicdario/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_000.txt",
      "chars": 263
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_001.txt",
      "chars": 271
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_002.txt",
      "chars": 268
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_003.txt",
      "chars": 269
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_004.txt",
      "chars": 226
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_005.txt",
      "chars": 308
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_006.txt",
      "chars": 316
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_007.txt",
      "chars": 280
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_008.txt",
      "chars": 184
    },
    {
      "language": "txt",
      "file": "attachments/2cf1c9dd7522/code/block_009.txt",
      "chars": 276
    }
  ],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/0Uy0g3t3S6kF4sESf-scaled.jpg",
      "alt": "Photo by Brigitte Tohm on Unsplash",
      "local_path": "attachments/2cf1c9dd7522/images/000.jpg",
      "bytes": 418627,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1v9UND7IoVZlSSwjl_klh2Q.jpeg",
      "alt": "Image 1 - Horizontal stacking explained (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/001.jpeg",
      "bytes": 55652,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1xEF4wFJEmRJD9L-159-XhA.jpeg",
      "alt": "Image 2 - Vertical stacking explained (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/002.jpeg",
      "bytes": 56940,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1PMEOBzHi8RJAACWPzsxYBw.png",
      "alt": "Image 3 - Horizontal stacking in Numpy (1) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/003.png",
      "bytes": 6629,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1i2G0Ewl50hYgHpXr-vSVnA.png",
      "alt": "Image 4 - Horizontal stacking in Numpy (2) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/004.png",
      "bytes": 6712,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1R1zCriBaaqCzkA_slq0pJQ.png",
      "alt": "Image 5 - Vertical stacking in Numpy (1) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/005.png",
      "bytes": 7027,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/154LPcfWT93EG8tYLindzEg.png",
      "alt": "Image 6 - Vertical stacking in Numpy (2) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/006.png",
      "bytes": 6956,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1U-Y1SPb_uHqCcBpe9e2KNg.png",
      "alt": "Image 7 - Stacking 1D arrays (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/007.png",
      "bytes": 5626,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1aRTvbOvtARP12Bfo5p-Lxg.png",
      "alt": "Image 8 - Stacking 2D arrays (1) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/008.png",
      "bytes": 9312,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1SLWHJUZTUEikCh3EiL1XRg.png",
      "alt": "Image 9 - Stacking 2D arrays (2) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/009.png",
      "bytes": 9145,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/10Ks_3zNo07hdGDixOqX3GA.png",
      "alt": "Image 10 - Numpy stacking in a loop (1) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/010.png",
      "bytes": 13250,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1ENIGf0Ul-5hsZfhe6OgQlA.png",
      "alt": "Image 11 - Numpy stacking in a loop (2) (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/011.png",
      "bytes": 8194,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/131wI-8YVec9xXEDez-zuzQ.png",
      "alt": "Image 12 - Numpy dstack (image by author)",
      "local_path": "attachments/2cf1c9dd7522/images/012.png",
      "bytes": 7494,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2019/12/0U9OgNJDKYR07MrJR.jpg",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/013.jpg",
      "bytes": 47467,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/Experiments-illustrated-.jpg",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/014.jpg",
      "bytes": 541236,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/12/1rhV3URvLEWEfBWu4S07vCw-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/015.jpeg",
      "bytes": 622689,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/1ArtYxGFlH3V4gis2MEXJCg.jpeg",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/016.jpeg",
      "bytes": 160964,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/11/0Tt0oeVC1bCnU9fY6.png",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/017.png",
      "bytes": 108197,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/057utp1tadb4iYMDS-scaled.jpg",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/018.jpg",
      "bytes": 402406,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/0WR69GyoGUavsSV2v-scaled.jpg",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/019.jpg",
      "bytes": 367554,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/02/1f6ct2Al6c9vkvVNn93zEWg.png",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/020.png",
      "bytes": 1305152,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/1MkXejtNAt5HN2f6RgKk6Iw.png",
      "alt": "",
      "local_path": "attachments/2cf1c9dd7522/images/021.png",
      "bytes": 29663,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [
    {
      "src": "https://www.youtube.com/c/TowardsDataScience",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/radecicdario/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/@radecicdario/membership"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/numpy/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/programming/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/python/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/towards-data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/images-as-data-structures-art-through-256-integers-8898bce17230/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/np-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/eustin.jvans/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/experiments-illustrated-can-1-change-behavior-more-than-100/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/btengels/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/understanding-convolutional-neural-networks-cnns-81dffc813a69/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/@brigittetohm"
    },
    {
      "type": "external",
      "href": "https://unsplash.com"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/computer-science"
    },
    {
      "type": "external",
      "href": "https://medium.com/@radecicdario/membership"
    },
    {
      "type": "external",
      "href": "https://betterdatascience.com/np-stack/"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=np.stack%28%29+-+How+To+Stack+two+Arrays+in+Numpy+And+Python&u=https%3A%2F%2Ftowardsdatascience.com%2Fnp-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=np.stack%28%29+-+How+To+Stack+two+Arrays+in+Numpy+And+Python&url=https%3A%2F%2Ftowardsdatascience.com%2Fnp-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=np.stack%28%29+-+How+To+Stack+two+Arrays+in+Numpy+And+Python&url=https%3A%2F%2Ftowardsdatascience.com%2Fnp-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    },
    {
      "type": "external",
      "href": "https://www.threads.net/@towardsdatascience"
    },
    {
      "type": "external",
      "href": "https://bsky.app/profile/towardsdatascience.com"
    },
    {
      "type": "external",
      "href": "https://thenewstack.io"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh"
    },
    {
      "type": "external",
      "href": "https://insightmediagroup.io/creator-network"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:48Z",
  "source_url": "https://towardsdatascience.com/np-stack-how-to-stack-two-arrays-in-numpy-and-python-fc910dd2d57a/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}