Pandas is an open-source Python Library providing high-performance data manipulation and analysis tool using its powerful data structures. The name Pandas is derived from the word Panel Data – an Econometrics from Multidimensional data. Series is a one-dimensional labelled array capable of holding data of any type i.e. integer, string, float, python objects, etc). The axis labels are collectively called index. To create a series, at first install the pandas library. We use pip to install any library in Python − pip install pandas Create a Pandas Series from a List Example We will create a series from a ... Read More
In this example, we will see how to sort an array in Numpy by the (N-1)th column. Sort an array by (n-1) th column using argsort() Example Let us see the first example to sort an array by (n-1)th column − import numpy as np # Creat a Numpy Array a = np.array([[9, 2, 3], [4, 5, 6], [7, 0, 5]]) print("Array = ", a) # The value of n n = 3 # Sort by n-1 column print("Sort by n-1 th column = ", a[a[:, (n-1)].argsort()]) Output Array ... Read More
In this tutorial, we will learn to print a triangle formed of '#' using JavaScript. You need to use nested loops to print a triangle formed of '#' in JavaScript. Loop is one of the features in programming languages that executes a set of instructions a several till the condition does not evaluate as false. Nested loops are the loops that contain a loop inside a loop itself. We are going to use two of loops in JavaScript to execute our task. Following are the loops we are using to print a triangle formed of '#' − for loop ... Read More
The range() method in Python is used to return a sequence object. It is used in Python 3.x The xrange() is used to generate sequence of number and used in Python 2.x. Therefore, there’s no xrange() in Python 3.x. Let us first learn about range() and xrange() one by one. The range() method in Python The range() method returns a sequence of numbers and has 3 parameters i.e. start, stop and step. Here’s the syntax − range(start, stop, step) Here, start − Integer specifying at which position to start. stop − Integer specifying at which position to stop. ... Read More
In this tutorial, we will learn how to merge two arrays in JavaScript. In JavaScript, we can merge two arrays in different approaches, and in this tutorial, we will see some of the approaches for doing this − Using the Array concate() method Using the spread operator Using the loop iteration Using the Array concate() method The Array concate() method merges two or multiple arrays. It is one of the best method to merge arrays in JavaScript. This method operates on an array, takes another array in the parameters, and returns a new one after merging these ... Read More
In Python, if you want to copy object, the assignment operator won’t fulfil the purpose. It creates bindings between a target and an object i.e., it never creates a new object. It only creates a new variable sharing the reference of the original object. To fix this, the copy module is provided. This module has generic shallow and deep copy operations. Shallow Copy A shallow copy constructs a new compound object and then inserts references into it to the objects found in the original. It uses the following method to copy objects − copy.copy(x) Return a shallow copy of x. ... Read More
In this tutorial, we will learn how to print object arrays in JavaScript. What is an object array or an array of objects? An array of objects is used to store a fixed-size sequential collection of identical elements and store many values in one variable. Next, we will see the options to print an array of objects in JavaScript. Using the stringify() Method of the JSON Object Here, we will learn how to stringify the object array. To correctly display an array of objects, we need to format the array as a JSON string. JSON.stringify() formats the array and gives ... Read More
The arrays in Python are ndarray objects. The matrix objects are strictly 2-dimensional whereas the ndarray objects can be multi-dimensional. To create arrays in Python, use the Numpy library. Matrices in Python Matrix is a special case of two-dimensional array where each data element is of strictly same size. Matrices are a key data structure for many mathematical and scientific calculations. Every matrix is also a two-dimensional array but not vice versa. Matrix objects are a subclass of ndarray, so they inherit all the attributes and methods of ndarrays. Example Create a Matrix and Display from numpy import * ... Read More
In this tutorial, we will learn to print the content of a JavaScript object. Objects are similar to variables, but they can contain many values. Javascript object values are written as key: value pairs, and each pair is separated by commas. It is used to access data from databases or any other sources. Following are the ways to print the content of JavaScript objects − Using the JSON.stringify() Method And using a for-in loop Using Object.values() Using the JSON.stringify() Method The JSON.stringify() is used to convert JavaScript Objects into a string. We have to use JSON.stringify() to send ... Read More
In this tutorial, we will learn how to preselect Dropdown using JavaScript Programmatically. A dropdown list is a toggle menu that allows the user to select one of several options. The options in this list are defined here in coding and are linked to a unique function. When you click or choose this option, that function is triggered and begins to work. A dropdown list allows us to select only one item from a list of options. To construct a basic dropdown list in HTML, the tab is combined with the, tab. Following that, JavaScript assists in performing ... Read More