Posts

Showing posts with the label arrays

Slicing of Numpy Arrays | Data Science tutorial| codin india

Image
Hello Friends, in this tutorial we will learn about what is indexing and slicing. Let us see one by one. What is indexing? Indexing is a term of defining something orderly. It is used when we want something in a specific range. Suppose you have multiple copies of the same item and you have to remember or recognize every item then you will give every item a unique name or number. That exactly what indexing is. In   Numpy Arrays   indexing start from 0 like   List   in   Python. EX:- myarr = np.array([101,102,103,104,105]) In the given example, the indexing start from zero. If I call the 3rd item from   myarr   array it will give me 104 from the array. What is slicing of array? Slicing of arrays indicates that calling the specific value or range of value from Array. Slicing of Array is almost the same as Slicing of string. We can fetch a specific value from the array, range of values from arrays, call values in reverse order and call value by jumping one or more element. You can slice ac

Array Concatenation and methods of stack | numpy array tutorial | Codin india

Image
    Numpy is Python module that is used for array creation, modification and creating sub arrays for numpy arrays. Concatenation of arrays Concatenation or joining of two arrays in Numpy, is primarily accomplished through the routines np.concatenate, np.vstack and np.hstack. Let us see all of the one by one. Concatenate:- It will concatenate two arrays and gives the output as one array. Let us see by code:- From the above code, it is clear that np.concatenate takes two argument as input and adds the value of both array and return the output as one array. Concatenate 3 or more arrays:- we can concatenate as any array we want. Let us talk, where the case of 3 arrays, we will concatenate all the 3 arrays Concatenation of same array:- We can also concatenate same array together. Like we can concatenate x + x. Let's see the Code:- NOTE:-   point here to be noted that, the arguments should be passed in [] brackets only.  np.concatenate([x, y]) 2-D or multidimensional Array Concatenation:

Introduction to Linked List| Data Structure with Python

Image
   Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at a contiguous location. The element are linked using pointers. Why Linked list is used:- Arrays can be used to store linear data of similar types, but arrays have the following limitations. Array's size is fixed. So we must know the highest limit of the array in advance. So we must declare the size of the array first and elements there after.  Inserting a new element is very expensive because the room has to be be created for the new elements and shift the existing elements. Ex :- Suppose we have arrays in sorted order   i.e. [1,2,3,4,6,7]  and we have to insert new element   i.e. [5]   in the array. So in order to maintain elements in sorted order, we have to place that element after suitable element. In this situation we have to shift the element   i.e. [6,7] by position 1. Now  we saw the arrays limitations. Let's understand the advantages of the Linked List over array.  Advantage

User Defined data structure - Python | codin india

Image
  In computer science, a data structure is a logical way of organizing data in computer memory so that it can be used effectively. A data structure allows data to be added, removed, stored and maintained in a structured manner. Python supports two types of data structures: 1. Non-primitive data types:- Python has list, set, tuples and dictionary as its non-primitive data types which can also be considered its in-built data structures. List Arrays Tuples Dictionaries 2. User-defined data structures:- Data Structures that aren't supported by python but can be programmed to reflect the same functionality using concepts supported by python are user-defined data structures. There are many data structures that can be implemented this way:- Linked List Stack Queue Tree  Graphs Hash map Linked List Data Structure:- A  Linked List  is a linear data structure, in which the elements are not stored at contiguous memory location. The elements in a linked list are linked using pointers. Python c