MySQL LIKE Query with Dynamic Array

AmitDiwan
Updated on 11-Dec-2020 05:23:57

2K+ Views

To implement LIKE query with dynamic array, the syntax is as follows −Exampleselect *from yourTableName    where yourColumnName2 like "%yourValue%"    order by yourColumnName1 asc    limit yourLimitValue;Let us create a table −Examplemysql> create table demo74    -> (    -> user_id int not null auto_increment primary key,    -> user_names varchar(250)    -> )    -> ; Query OK, 0 rows affected (0.67Insert some records into the table with the help of insert command −Examplemysql> insert into demo74(user_names) values("John Smith1, John Smith2, John Smith3"); Query OK, 1 row affected (0.18 mysql> insert into demo74(user_names) values("John Smith1"); Query OK, ... Read More

Select All Records Containing Specific Number in MySQL

AmitDiwan
Updated on 11-Dec-2020 05:20:16

914 Views

To select all records with specific numbers, use the FIND_IN_SET() in MySQL.Let us create a table −Examplemysql> create table demo73    -> (    -> interest_id varchar(100),    -> interest_name varchar(100)    -> ); Query OK, 0 rows affected (1.48Insert some records into the table with the help of insert command −Examplemysql> insert into demo73 values("100, 101, 103, 105", "SSC"); Query OK, 1 row affected (0.34 mysql> insert into demo73 values("105, 103, 1005, 1003, 104", "Computer"); Query OK, 1 row affected (0.10 mysql> insert into demo73 values("110, 105, 104, 111", "Novel"); Query OK, 1 row affected (0.31Display records ... Read More

Convert MM-YY to YYYY-MM-DD in MySQL

AmitDiwan
Updated on 11-Dec-2020 05:17:06

874 Views

To convert, use str_to_date() in MySQLLet us create a table and add date records −Examplemysql> create table demo72    -> (    -> due_date varchar(40)    -> ); Query OK, 0 rows affected (2.96 sec)Insert some records into the table with the help of insert command −Examplemysql> insert into demo72 values("11/15"); Query OK, 1 row affected (0.26 sec) mysql> insert into demo72 values("02/20"); Query OK, 1 row affected (0.09 sec) mysql> insert into demo72 values("07/95"); Query OK, 1 row affected (0.15 sec)Display records from the table using select statement −Examplemysql> select *from demo72;This will produce the following output ... Read More

Implement Nelder-Mead Algorithm Using SciPy in Python

AmitDiwan
Updated on 10-Dec-2020 13:47:25

716 Views

SciPy library can be used to perform complex scientific computations at speed, with high efficiency. Nelder-Mead algorithm is also known as simple search algorithm.It is considered to be one of the best algorithms that can be used to solve parameter estimation problems, and statistical problems. Relevant to use this algorithm in situations where the values of functions are uncertain or have lots of noise associated with it.This algorithm can also be used to work with discontinuous functions which occur frequently in statistics. It is a simple algorithm and it is easy to understand as well. Used to minimize the parameters ... Read More

Find Minimum of Scalar Function in SciPy Using Python

AmitDiwan
Updated on 10-Dec-2020 13:45:53

180 Views

Finding the minimum of a scalar function is an optimization problem. Optimization problems help improve the quality of the solution, thereby yielding better results with higher performances. Optimization problems are also used for curve fitting, root fitting, and so on.Let us see an example −Exampleimport matplotlib.pyplot as plt from scipy import optimize import numpy as np print("The function is defined") def my_func(a):    return a*2 + 20 * np.sin(a) plt.plot(a, my_func(a)) print("Plotting the graph") plt.show() print(optimize.fmin_bfgs(my_func, 0))OutputOptimization terminated successfully.    Current function value: -23.241676    Iterations: 4    Function evaluations: 18    Gradient evaluations: 6 [-1.67096375]ExplanationThe required packages are imported.A ... Read More

Perform Discrete Fourier Transform in SciPy Python

AmitDiwan
Updated on 10-Dec-2020 13:44:39

552 Views

Discrete Fourier Transform, or DFT is a mathematical technique that helps in the conversion of spatial data into frequency data.Fast Fourier Transformation, or FTT is an algorithm that has been designed to compute the Discrete Fourier Transformation of spatial data.The spatial data is usually in the form of a multidimensional array. Frequency data refers to data that contains information about the number of signals or wavelengths in a specific period of time.Let us see how this DFT can be achieved using the ‘SciPy’ library.The graph is created using the matplotlib library and data is generated using the Numpy library −ExampleFrom ... Read More

Calculate Eigenvalues and Eigenvectors of a Matrix in Python using Scipy

AmitDiwan
Updated on 10-Dec-2020 13:42:50

2K+ Views

Eigen vectors and Eigen values find their uses in many situations. The word ‘Eigen’ in German means ‘own’ or ‘typical’. An Eigen vector is also known as a ‘characteristic vector’. Suppose we need to perform some transformation on a dataset but the given condition is that the direction of data in the dataset shouldn’t change. This is when Eigen vectors and Eigen values can be used.Given a square matrix (a matrix where the number of rows is equal to the number of columns), an Eigen value and an Eigen vector fulfil the below equation.Eigen vectors are computed after finding the ... Read More

Access Top N Elements from Series Data Structure in Python

AmitDiwan
Updated on 10-Dec-2020 13:40:49

125 Views

We have previously used slicing with the help of operator ‘:’, which is used in the case of extracting top ‘n’ elements from series structure. It helps assign a range to the series elements that will later be displayed.Let us see an example −Example Live Demoimport pandas as pd my_data = [34, 56, 78, 90, 123, 45] my_index = ['ab', 'mn' ,'gh', 'kl', 'wq', 'az'] my_series = pd.Series(my_data, index = my_index) print("The series contains following elements") print(my_series) n = 3 print("Top 3 elements are :") print(my_series[:n])OutputThe series contains following elements ab  34 mn  56 gh  78 kl  90 wq  123 az ... Read More

Access Data from a Series Data Structure in Python

AmitDiwan
Updated on 10-Dec-2020 13:39:25

128 Views

The ability to index elements and access them using their positional index values serves a great purpose when we need to access specific values.Let us see how series data structure can be index to get value from a specific index.Example Live Demoimport pandas as pd my_data = [34, 56, 78, 90, 123, 45] my_index = ['ab', 'mn' ,'gh', 'kl', 'wq', 'az'] my_series = pd.Series(my_data, index = my_index) print("The series contains following elements") print(my_series) print("The second element (zero-based indexing)") print(my_series[2]) print("Elements from 2 to the last element are") print(my_series[2:])OutputThe series contains following elements ab  34 mn  56 gh  78 kl  90 wq ... Read More

Create Series Data Structure in Python Using Dictionary and Index Values

AmitDiwan
Updated on 10-Dec-2020 13:37:38

177 Views

Let us understand how series data structure can be created using dictionary, as well as specifying the index values, i.e., customized index values to the series.Dictionary is a Python data structure that has a mapping kind of structure- a key, value pair.Example Live Demoimport pandas as pd my_data = {'ab' : 11., 'mn' : 15., 'gh' : 28., 'kl' : 45.} my_index = ['ab', 'mn' ,'gh', 'kl'] my_series = pd.Series(my_data, index = my_index) print("This is series data structure created using dictionary and specifying index values") print(my_series)OutputThis is series data structure created using dictionary and specifying index values ab  11.0 mn  15.0 ... Read More

Advertisements