Server Side Programming Articles - Page 555 of 2650

Kruskal's Minimum Spanning Tree Algorithm-Greedy algorithm in C++

Prateek Jangid
Updated on 07-Mar-2022 07:27:02

4K+ Views

A spanning tree is a linked and undirected graph subgraph that connects all vertices. Many spanning trees can exist in a graph. The minimum spanning tree (MST) on each graph is the same weight or less than all other spanning trees. Weights are assigned to edges of spanning trees and the sum is the weight assigned to each edge. As V is the number of vertices in the graph, the minimum spanning tree has edges of (V - 1), where V is the number of edges.Finding minimum spanning tree using Kruskal’s algorithmAll of the edges should be arranged in a ... Read More

Evaluate a 2D Legendre series at points (x, y) with 3D array of coefficient in Python

AmitDiwan
Updated on 07-Mar-2022 07:21:00

141 Views

To evaluate a 2D Legendre series at points x, y, use the polynomial.legendre.legval2d() method in Python Numpy. The method returns the values of the two dimensional Legendre series at points formed from pairs of corresponding values from x and y.The 1st parameter is x, y. The two dimensional series is evaluated at the points (x, y), where x and y must have the same shape. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn’t an ndarray it is treated as a scalar.The 2nd parameter ... Read More

Evaluate a 2D Legendre series at points (x, y) in Python

AmitDiwan
Updated on 07-Mar-2022 07:19:06

290 Views

To evaluate a 2D Legendre series at points x, y, use the polynomial.legendre.legval2d() method in Python Numpy. The method returns the values of the two dimensional Legendre series at points formed from pairs of corresponding values from x and y.The 1st parameter is x, y. The two dimensional series is evaluated at the points (x, y), where x and y must have the same shape. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn’t an ndarray it is treated as a scalar.The 2nd parameter ... Read More

Evaluate a Legendre series at list of points x in Python

AmitDiwan
Updated on 07-Mar-2022 07:17:24

167 Views

To evaluate a Legendre series at points x, use the polynomial.legendre.legval() method in Python Numpy. The 1st parameter is x. If x is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, x or its elements must support addition and multiplication with themselves and with the elements of c.The 2nd parameter, C, an array of coefficients ordered so that the coefficients for terms of degree n are contained in c[n]. If c is multidimensional the remaining indices enumerate multiple polynomials. In the two dimensional case the ... Read More

How to use pandas series.fillna() to replace missing values?

Gireesha Devara
Updated on 07-Mar-2022 07:22:57

3K+ Views

The pandas series.fillna() method is used to replace missing values with a specified value. This method replaces the Nan or NA values in the entire series object.The parameters of pandas fillna are as follows −Value − it allows us to specify a particular value to replace Nan’s, by default it takes None.Method − it is used to fill the missing values in the reindexed Series. It takes any of these values like ‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, and None(default).Inplace − this parameter takes a boolean value. If it takesTrue, then the modifications are applied to the original series object itself, otherwise, ... Read More

Evaluate a 3D Legendre series on the Cartesian product of x, y and z with 4d array of coefficient in Python

AmitDiwan
Updated on 07-Mar-2022 07:14:47

174 Views

To evaluate a 3D Legendre series on the Cartesian product of x, y and z use the polynomial.legendre.leggrid3d() method in Python Numpy. The method returns the values of the three dimensional Chebyshev series at points in the Cartesian product of x, and z. If c has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape.The 1st parameter is x, y, z. The three dimensional series is evaluated at the points in the Cartesian product of x, y and z. If ... Read More

What is the basic operation of pandas Series.factorize() function?

Gireesha Devara
Updated on 07-Mar-2022 07:13:36

214 Views

The pandas Series.factorize() method is used to encode the series object as an enumerated type or categorical variable. This method generates the numeric representation of the series data.The output of this Series.factorize() method is a tuple and it has two elements one is indicating codes and another element indicates uniques.Example 1In the following example, we will see how the series.factorize() method encodes the elements of the series object.# importing pandas package import pandas as pd # create a series s = pd.Series({'A':"aa", 'B':"bb", "C":"cc"}) print(s) result = s.factorize() print(result)ExplanationHere the series object is created by using a python ... Read More

Evaluate a 3D Legendre series on the Cartesian product of x, y and z in Python

AmitDiwan
Updated on 07-Mar-2022 07:11:23

207 Views

To evaluate a 3D Legendre series on the Cartesian product of x, y and z use the polynomial.legendre.leggrid3d() method in Python Numpy. The method returns the values of the three dimensional Chebyshev series at points in the Cartesian product of x, and z. If c has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape.The 1st parameter is x, y, z. The three dimensional series is evaluated at the points in the Cartesian product of x, y and z. If ... Read More

Integrate a Hermite_e series in Python

AmitDiwan
Updated on 07-Mar-2022 07:07:58

155 Views

To integrate a Hermite_e series, use the hermite_e.hermeint() method in Python. The 1st parameter, c is an array of Hermite_e series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index. The 2nd parameter, m is an order of integration, must be positive. (Default: 1).The 3rd parameter, k is an integration constant(s). The value of the first integral at lbnd is the first value in the list, the value of the second integral at lbnd is the second value, etc. If k == [] (the default), all ... Read More

How to unnest (explode) a row in a pandas series?

Gireesha Devara
Updated on 07-Mar-2022 07:10:17

1K+ Views

If some of the elements in the series object have lists, then we can unnest those list elements into multiple rows of the series object. Unnesting is nothing but exploding the lists into rows.So this transformation can be done easily with the help of the pandas series.explode() method. This method is used to transform list-like elements of a series object into rows, and the index will be duplicated for these rows.The ignore_index is the only parameter for this method and it takes boolean values, False is the default one, and True means the resulting index will be labeled from 0 ... Read More

Advertisements