How To Append Numpy Arrays

ExploreEXPLORE THE CATALOGSupercharge your career with 700+ hands-on coursesView All CoursesPythonJavaJavaScriptCReactDockerVue JSRWeb DevDevOpsAWSC#LEARNING TOOLSExplore the industry's most complete learning platformCoursesLevel up your skillsSkill PathsAchieve learning goalsProjectsBuild real-world applicationsMock InterviewsNewAI-Powered interviewsPersonalized PathsGet the right resources for your goalsLEARN TO CODECheck out our beginner friendly courses.PricingFor BusinessResourcesNewsletterCurated insights on AI, Cloud & System DesignBlogFor developers, By developersFree CheatsheetsDownload handy guides for tech topicsAnswersTrusted answers to developer questionsGamesSharpen your skills with daily challengesSearchCoursesLog InJoin for freeHow to append numpy arrays

numpy.append() is used to append values to the end of an array. It takes in the following arguments:

  • arr: values are attached to a copy of this array.

  • values: these values are appended to arr.

  • axis: this is an optional parameter that specifies the axis along with which values are appended. If the axis is not specified, then arr and values are flattened out.

numpy.append() does not alter the original array, instead, it returns a new array.

Take a look at the function signature below:

svg viewer

C​ode

In the first code snippet, the axis is not specified,​ so arr and values are flattened out.

import numpy as npprint(np.append([1, 2, 3], [['a', 'b', 'c'], [7, 8, 9]]))Run

In the following code snippet, values are appended along axis 1.

import numpy as npprint(np.append([[4, 5, 6]], [[7, 8, 9]], axis = 1))# Try setting the axis to 0Run

For more details, refer to the official documentation.

Relevant Answers

Explore Courses

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved

Tag » Add Element Np Array Python