code-rag-bench/online-tutorials huggingface dataset:
Meaning of numbers in “col-md-4”,“ col-xs-1”, “col-lg-2” in Bootstrap

26 Feb, 2019
The grid system in Bootstrap helps you to align text side-by-side and uses a series of container, rows and column. The Grid system in Bootstrap uses ems and rems for defining most sizes whereas pxs are used for grid breakpoints and container widths. Bootstrap Grid System allows up to 12 columns across the page. You can use each of them individually or merge them together for wider columns. You can use all combinations of values summing up to 12. You can use 12 columns each of width 1, or use 4 columns each of width 3 or any other combination.
There are mainly five class in grid system which are listed below:
.col- Extra Small ( < 576 px )
.col-sm- Small ( >= 576 px )
.col-md- Medium ( >= 768 px )
.col-lg- Large ( >= 992 px )
.col-xl- Extra Large ( >= 1200 px )
Bootstrap provides 12 columns per row which is made available in the Column class. So, you can control the width of column using specifying numbers in .col-*, where * means the width of the column in numbers.
col-md-4: This class is used when the device size is medium or greater than 768px and the maximum width of container is 720px and you want the width equal to 4 columns.
col-xs-1: This class is used when the device size is extra small (mobile) and when you want the width to be equal to 1 column.
col-lg-2: This class is used when the device size is large or greater than 992px and the maximum width of container is 960px and when you want size equal to 2 columns.
Example:
<!DOCTYPE html><html>  <head>    <title>        Bootstrap numbers col-md-4, col-xs-1, col-lg-2    </title>          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">           <!-- jQuery library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>           <!-- Latest compiled JavaScript -->    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js">    </script></head>   <body>    <div class="container">        <div class=" row bg-primary col-lg-2">col-lg-2</div>        <div class=" row bg-success col-xs-1">col-xs-1</div>        <div class=" row bg-danger col-md-4">col-md-4</div>    </div></body>  </html>
Output:
Picked
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to pass data into a bootstrap modal?
How to set Bootstrap Timepicker using datetimepicker library ?
How to Show Images on Click using HTML ?
How to Use Bootstrap with React?
Difference between Bootstrap 4 and Bootstrap 5
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python | Operation to each element in list

13 May, 2020
Given a list, we always come across situations in which we require to apply certain function to each element in a list. This can be easily done by applying a loop and performing an operation to each element. But having shorthands to solve this problem is always beneficial and helps to focus more on important aspects of problem. Let’s discuss certain ways in which each element of list can be operated.
Method #1 : Using list comprehensionThis method performs the same task in the background as done by the looping constructs. The advantage this particular method provides is that this is a one liner and also improves code readability.
# Python3 code to demonstrate # operations on each list element# using list comprehension  # initializing list test_list = ["geeks", "for", "geeks", "is", "best"]  # printing original listprint ("The original list is : " + str(test_list))  # operations on each list element# using list comprehension# uppercasing each elementres = [i.upper() for i in test_list]  # printing resultprint ("The uppercased list is : " + str(res))
The original list is : ['geeks', 'for', 'geeks', 'is', 'best']
The uppercased list is : ['GEEKS', 'FOR', 'GEEKS', 'IS', 'BEST']

 Method #2 : Using map()Using map function, one can easily associate an element with the operation one wishes to perform. This is the most elegant way to perform or solve this kind of problems.
# Python3 code to demonstrate # operations on each list element# using map()  # initializing list test_list = ["Geeks", "foR", "gEEks", "IS", "bEST"]  # printing original listprint ("The original list is : " + str(test_list))  # operations on each list element# using map()# lowercasing each elementres = list(map(str.lower, test_list))  # printing resultprint ("The lowercased list is : " + str(res))
The original list is : ['Geeks', 'foR', 'gEEks', 'IS', 'bEST']
The uppercased list is : ['geeks', 'for', 'geeks', 'is', 'best']

AllBoutStudies
Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to move Files and Directories in Python

29 Dec, 2020
Python provides functionality to move files or directories from one location to another location. This can be achieved using shutil.move() function from shutil module. shutil.move() method Recursively moves a file or directory (source) to another location (destination) and returns the destination. If the destination directory already exists then src is moved inside that directory. If the destination already exists but is not a directory then it may be overwritten depending on os.rename() semantics.
Syntax: shutil.move(source, destination, copy_function = copy2)
Parameters:source: A string representing the path of the source file.destination: A string representing the path of the destination directory.copy_function (optional): The default value of this parameter is copy2. We can use other copy functions like copy, copytree, etc for this parameter.
Return Value: This method returns a string that represents the path of a newly created file.
Inside Test:
Inside A:
We want to move directory B into directory A. Below is the implementation.
# Python program to move# files and directories    import shutil  # Source pathsource = "D:\Pycharm projects\gfg\Test\B"  # Destination pathdestination = "D:\Pycharm projects\gfg\Test\A"  # Move the content of# source to destinationdest = shutil.move(source, destination)  # print(dest) prints the # Destination of moved directory
Output:
Inside test:
Inside A:
Example #2: Now let’s suppose we want to move all the sub-directories and files of above directory A to directory G using shutil.copytree() and the destination directory does not exist. Below is the implementation.
# Python program to move# files and directories    import shutil  # Source pathsource = "D:\Pycharm projects\gfg\Test\A"  # Destination pathdestination = "D:\Pycharm projects\gfg\Test\G"  # Move the content of# source to destinationdest = shutil.move(source, destination, copy_function = shutil.copytree)  # print(dest) prints the# Destination of moved directory
Output:
Inside Test:
Inside G:
Python os-module-programs
python-file-handling
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Introduction To PYTHON
Python – Sharpen and blur filtering using pgmagick

05 Jul, 2021
Sharpening refers to increase contrast b/w light and dark regions and make image more defined and brings out image features. There are three main reasons to sharpen your image: to overcome blurring introduced by camera equipment, to draw attention to certain areas and to increase legibility. If a blurry text is present in image it becomes easy to read.Now let’s learn how can we perform image sharpening in pgmagick library in python. We use sharpen() function to sharpen an image.Code :
Python3
# importing libraryfrom pgmagick import Image img = Image('koala.jpg') # sharpening imageimg.sharpen(2)img.write('sharp_koala.jpg')
Output :  
 
Blurring makes an image unclear and foggy. It doubtlessly decrease the clarity of an image. One is not able to see small edges if the image is blurred. Blur is a visual effect that makes the edges of text or images appear fuzzy or out of focus is referred to as a blur. Let’s see how can we blur image use pgmagick in Python. 
Python3
# importing libraryfrom pgmagick.api import Image img = Image('koala.jpeg') # blur imageimg.blur(10, 5)img.write('blur_koala.jpeg')
Output :  
 
 
kalrap615
Python-pgmagick
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
Python Dictionary
sum() function in Python
Print lists in Python (5 Different Ways)
Different ways to create Pandas Dataframe
Queue in Python
Python | Pandas Dataframe/Series.head() method

01 Oct, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas head() method is used to return top n (5 by default) rows of a data frame or series.
Syntax: Dataframe.head(n=5)
Parameters:n: integer value, number of rows to be returned
Return type: Dataframe with top n rows
To download the data set used in following example, click here.In the following examples, the data frame used contains data of some NBA players. The image of data frame before any operations is attached below.
Example #1:
In this example, top 5 rows of data frame are returned and stored in a new variable. No parameter is passed to .head() method since by default it is 5.
# importing pandas moduleimport pandas as pd  # making data framedata = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")  # calling head() method # storing in new variabledata_top = data.head()  # displaydata_top
Output:As shown in the output image, it can be seen that the index of returned rows is ranging from 0 to 4. Hence, top 5 rows were returned.
 Example #2: Calling on Series with n parameter()
In this example, the .head() method is called on series with custom input of n parameter to return top 9 rows of the series.
# importing pandas moduleimport pandas as pd  # making data framedata = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")  # number of rows to returnn = 9  # creating seriesseries = data["Name"]  # returning top n rowstop = series.head(n = n)  # displaytop
Output:As shown in the output image, top 9 rows ranging from 0 to 8th index position were returned.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python pandas-methods
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Python map() function
Adding new column to existing DataFrame in Pandas
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
Iterate over a list in Python
How to Toggle Password Visibility using HTML and JavaScript ?

24 Sep, 2021
Passwords are those input types that appear as ******. It can be shown to the user by adding a feature of the eye icon so that the user can see the password.
Approach
We will display the use of two image icons “eye.png” and “eyeslash.png“
Toggle these images using JavaScript.
We will toggle the type of input field of password ( text -> password and password -> text )
Example:
HTML
<!DOCTYPE html><html>  <body>    <h2 style="color:green">        GeeksforGeeks    </h2>          <div class="col-sm-6">        <form method="post" class="form-group ">            Username            <input type="text" name="username"                 autofocus="" autocapitalize="none"                 autocomplete="username" required=""                id="id_username" class="form-control">                              Password            <input type="password" name="password"                 class="form-control"                 autocomplete="current-password" required=""                id="id_password">              <img src="https://media.geeksforgeeks.org/wp-content/uploads/20210917150049/eyeslash-300x240.png"                width="1.8%" height="1%"                 style="margin-left: -5%;display:inline;                vertical-align: middle"                 id="togglePassword">              <button type="submit" class="btn btn-primary">                Login            </button>        </form>    </div></body>  <script>    const togglePassword =         document.querySelector('#togglePassword');              const password = document.querySelector('#id_password');      togglePassword.addEventListener('click', function (e) {          // Toggle the type attribute        const type = password.getAttribute(            'type') === 'password' ? 'text' : 'password';        password.setAttribute('type', type);          // Toggle the eye slash icon        if (togglePassword.src.match("https://media.geeksforgeeks.org/wp-content/uploads/20210917150049/eyeslash.png")) {            togglePassword.src ="https://media.geeksforgeeks.org/wp-content/uploads/20210917145551/eye.png";        } else {            togglePassword.src ="https://media.geeksforgeeks.org/wp-content/uploads/20210917150049/eyeslash.png";        }    });</script>  </html>
Output:        
toggle the Password field
Blogathon-2021
HTML-Questions
JavaScript-Methods
JavaScript-Questions
Blogathon
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to split the element of a given NumPy array with spaces?

25 Oct, 2020
To split the elements of a given array with spaces we will use numpy.char.split(). It is a function for doing string operations in NumPy. It returns a list of the words in the string, using sep as the delimiter string for each element in arr.
Parameters:arr : array_like of str or unicode.Input array.sep : [ str or unicode, optional] specifies the separator to use when splitting the string.maxsplit : how many maximum splits to do.
Returns : [ndarray] Output Array containing of list objects.
Example 1:
Python3
import numpy as np    # Original Arrayarray = np.array(['PHP C# Python C Java C++'], dtype=np.str)print(array)  # Split the element of the said array with spacessparr = np.char.split(array)print(sparr)
Output :
['PHP C# Python C Java C++']
[list(['PHP', 'C#', 'Python', 'C', 'Java', 'C++'])]

Example 2:
Python3
import numpy as np    # Original Arrayarray = np.array(['Geeks For Geeks'], dtype=np.str)print(array)  # Split the element of the said array # with spacessparr = np.char.split(array)print(sparr)
Output: 
['Geeks For Geeks']
[list(['Geeks', 'For', 'Geeks'])]

Example 3:
Python3
import numpy as np    # Original Arrayarray = np.array(['DBMS OOPS DS'], dtype=np.str)print(array)  # Split the element of the said array # with spacessparr = np.char.split(array)print(sparr)
Output:
['DBMS OOPS DS']
[list(['DBMS', 'OOPS', 'DS'])]

Python numpy-String Operation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
TimeUnit convert() method in Java with Examples

15 Oct, 2018
The convert() method of TimeUnit Class is used to convert the given time duration in the given unit to this unit. Since conversion involves from larger to smaller or smaller to larger units, loss of precision and overflow can occur while using this method.
Syntax:
public long convert(long sourceDuration, 
                        TimeUnit sourceUnit)
Parameters: This method accepts two mandatory parameters:
sourceDuration– which is the time duration in the given sourceUnit
sourceUnit– which is the unit of the sourceDuration argument
Return Value: This method returns the converted duration in this unit, or Long.MIN_VALUE if conversion would negatively overflow, or Long.MAX_VALUE if it would positively overflow.
Below program illustrate the implementation of TimeUnit convert() method:
Program 1: To convert Minutes to MilliSeconds
// Java program to demonstrate// convert() method of TimeUnit Class  import java.util.concurrent.*;import java.util.Date;  class GFG {    public static void main(String args[])    {        // Get time to be converted in Minutes        long timeInMinutes = 55L;          // Create a TimeUnit object        TimeUnit time = TimeUnit.MILLISECONDS;          // Convert Minutes to milliseconds        // using convert() method        System.out.println("Time " + timeInMinutes                           + " minutes in milliSeconds = "                           + time.convert(timeInMinutes,                                          TimeUnit.MINUTES));    }}
Time 55 minutes in milliSeconds = 3300000

Program 2: To convert Seconds to Minutes
// Java program to demonstrate// convert() method of TimeUnit Class  import java.util.concurrent.*;import java.util.Date;  class GFG {    public static void main(String args[])    {        // Get time to be converted in Seconds        long timeInSec = 300L;          // Create a TimeUnit object        TimeUnit time = TimeUnit.MINUTES;          // Convert Seconds to Minutes        // using convert() method        System.out.println("Time " + timeInSec                           + " seconds in minutes = "                           + time.convert(timeInSec,                                          TimeUnit.SECONDS));    }}
Time 300 seconds in minutes = 5

Java - util package
Java-Functions
Java-TimeUnit
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Introduction to Java
Exceptions in Java
Java Programming Examples
Strings in Java
Functional Interfaces in Java
Generics in Java
Abstraction in Java
Differences between JDK, JRE and JVM
PyQtGraph – Line Graph

19 Aug, 2021
In this article we will see how we can create line graph in the PyQtGraph module. PyQtGraph is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications. Its primary goals are to provide fast, interactive graphics for displaying data (plots, video, etc.) and second is to provide tools to aid in rapid application development (for example, property trees such as used in Qt Designer).A line chart or line plot or line graph or curve chart is a type of chart which displays information as a series of data points called ‘markers’ connected by straight line segments. It is a basic type of chart common in many fields. Line graph is created with the help of plot class in PyQtGraph. 
In order to plot the bar graph in PyQtGraph we have to do the following 1. Importing the PyQtgraph module 2. Creating a plot window 3. Create or get the plotting data i.e horizontal and two vertical data for two lines 4. Set range to the plot window 5. Plot the line on the plot window and specifying properties of the line  
Below is the implementation  
Python3
# importing pyqtgraph as pgimport pyqtgraph as pg # importing QtCore and QtGui from the pyqtgraph modulefrom pyqtgraph.Qt import QtCore, QtGui # importing numpy as npimport numpy as np # define the datatitle = "GeeksforGeeks PyQtGraph" # y values to plot by line 1y = [2, 8, 6, 8, 6, 11, 14, 13, 18, 19] # y values to plot by line 2y2 = [3, 1, 5, 8, 9, 11, 16, 17, 14, 16]x = range(0, 10) # create plot window objectplt = pg.plot() # showing x and y gridsplt.showGrid(x = True, y = True) # adding legendplt.addLegend() # set properties of the label for y axisplt.setLabel('left', 'Vertical Values', units ='y') # set properties of the label for x axisplt.setLabel('bottom', 'Horizontal Values', units ='s') # setting horizontal rangeplt.setXRange(0, 10) # setting vertical rangeplt.setYRange(0, 20) # setting window title to the plot windowplt.setWindowTitle(title) # ploting line in green color# with dot symbol as x, not a mandatory fieldline1 = plt.plot(x, y, pen ='g', symbol ='x', symbolPen ='g',                          symbolBrush = 0.2, name ='green') # ploting line2 with blue color# with dot symbol as oline2 = plt.plot(x, y2, pen ='b', symbol ='o', symbolPen ='b',                             symbolBrush = 0.2, name ='blue') # main methodif __name__ == '__main__':         # importing system    import sys         # Start Qt event loop unless running in interactive mode or using    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):        QtGui.QApplication.instance().exec_()
Output :  
 
kapoorsagar226
Python-gui
Python-PyQtGraph
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
How to get Azure VM activity logs using PowerShell?

To get the Azure VM activity logs with PowerShell, we need to use the Get-AzLog command. Before running, AZ commands make sure that you are connected to the Azure Account using (ConnectAzAccount) and the subscription (Set-AzContext).
We have the below TestVM, we need to retrieve activity logs and we need its resource id. We will get the resource ID using,
PS C:\> $vm = Get-AzVM -VMName TestVM
PS C:\> $vm.Id
We need to use this ID in the Get-AzLog command to retrieve the activity logs.
PS C:\> Get-AzLog -ResourceId $vm.Id
It will provide all the azure events for that specific resource group and you can see the number of properties. If we need to retrieve the only properties which are shown in the azure activity log on the portal, you can use the below command.
(Get-AzLog -ResourceId $vm.Id) | Select
@{N='VMName';E={$vm.Name}},ResourceGroupName,
@{N='Message';E={$_.OperationName.LocalizedValue}}, Level, Caller, EventTimestamp |
ft -AutoSize
You can filter the event with a specific level. For example, to filter only warning logs,
(Get-AzLog -ResourceId $vm.Id) | where{$_.Level -eq "Warning"} | Select
@{N='VMName';E={$vm.Name}},ResourceGroupName,
@{N='Message';E={$_.OperationName.LocalizedValue}},Level, Caller, EventTimestamp
You can add the start and end times as shown below.
Get-AzLog -ResourceId $vm.Id -StartTime 2021-03-01 -EndTime
2021-05-25 -MaxRecord 20 | `
   Select @{N='VMName';E={$vm.Name}},ResourceGroupName,
@{N='Message';E={$_.OperationName.LocalizedValue}},Level,
Caller, EventTimestamp
Calculate the Euclidean distance using NumPy

05 Jul, 2021
In simple terms, Euclidean distance is the shortest between the 2 points irrespective of the dimensions. In this article to find the Euclidean distance, we will use the NumPy library. This library used for manipulating multidimensional array in a very efficient way. Let’s discuss a few ways to find Euclidean distance by NumPy library.
Method #1: Using linalg.norm() 
Python3
# Python code to find Euclidean distance# using linalg.norm() import numpy as np # initializing points in# numpy arrayspoint1 = np.array((1, 2, 3))point2 = np.array((1, 1, 1)) # calculating Euclidean distance# using linalg.norm()dist = np.linalg.norm(point1 - point2) # printing Euclidean distanceprint(dist)
Output:
2.23606797749979
Method #2: Using dot() 
Python3
# Python code to find Euclidean distance# using dot() import numpy as np # initializing points in# numpy arrayspoint1 = np.array((1, 2, 3))point2 = np.array((1, 1, 1)) # subtracting vectortemp = point1 - point2 # doing dot product# for finding# sum of the squaressum_sq = np.dot(temp.T, temp) # Doing squareroot and# printing Euclidean distanceprint(np.sqrt(sum_sq))
Output:
2.23606797749979
Method #3: Using square() and sum() 
Python3
# Python code to find Euclidean distance# using sum() and square() import numpy as np # initializing points in# numpy arrayspoint1 = np.array((1, 2, 3))point2 = np.array((1, 1, 1)) # finding sum of squaressum_sq = np.sum(np.square(point1 - point2)) # Doing squareroot and# printing Euclidean distanceprint(np.sqrt(sum_sq))
Output:
2.23606797749979
abhishek0719kadiyan
Python numpy-Linear Algebra
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How can we delete all rows from a MySQL table?

We can use either TRUNCATE statement or DROP statement to delete all the rows from the table. It can also be done with the help of DELETE statement but in that case WHERE clause must identify all the rows of the table. As we know that both TRUNCATE and DELETE statement will not delete the structure of the table but still it is better to use TRUNCATE statement rather than DELETE statement. DROP statement will delete table’s structure also.
TRUNCATE statement
TRUNCATE table table_name:

DROP statement
DROP table table_name:
How to parse float with two decimal places in JavaScript?

To parse float with two decimal places, use the concept of toFixed(2). Following is the code −
var price = 178932.89;
var tax = 7.9;
var totalPrice = price*tax;
console.log("The actual value="+totalPrice);
var gettingTwoPlacedValues = parseFloat(totalPrice).toFixed(2);
console.log("After getting two placed values="+gettingTwoPlacedValues);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo142.js. This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo142.js
The actual value=1413569.8310000002
After getting two placed values=1413569.83
How to do Fuzzy Matching on Pandas Dataframe Column Using Python?

We will match words in the first DataFrame with words in the second DataFrame. For closest matches, we will use threshold. We took the value of threshold as 70 i.e., match occurs when the strings at more than 70% close to each other.
Let us first create Dictionaries and convert to pandas dataframe −
# dictionaries
d1 = {'Car': ["BMW", "Audi", "Lexus", "Mercedes", "Rolls"]}

d2 = {'Car': ["BM", "Audi", "Le", "MERCEDES", "Rolls Royce"]}

# convert dictionaries to pandas dataframes
df1 = pd.DataFrame(d1)
df2 = pd.DataFrame(d2)
Now, convert dataframe column to list of elements for fuzzy matching −
myList1 = df1['Car'].tolist()
myList2 = df2['Car'].tolist()
Following is the complete code −
import pandas as pd
from fuzzywuzzy import fuzz
from fuzzywuzzy import process

# dictionaries
d1 = {'Car': ["BMW", "Audi", "Lexus", "Mercedes", "Rolls"]}

d2 = {'Car': ["BM", "Audi", "Le", "MERCEDES", "Rolls Royce"]}

# convert dictionaries to pandas dataframes
df1 = pd.DataFrame(d1)
df2 = pd.DataFrame(d2)

# printing the pandas dataframes
print("Dataframe 1 = \n",df1)
print("Dataframe 2 = \n",df2)

# empty lists for storing the matches later
match1 = []
match2 = []
k = []

# converting dataframe column to list of elements for fuzzy matching
myList1 = df1['Car'].tolist()
myList2 = df2['Car'].tolist()

threshold = 70

# iterating myList1 to extract closest match from myList2
for i in myList1:
   match1.append(process.extractOne(i, myList2, scorer=fuzz.ratio))
df1['matches'] = match1
for j in df1['matches']:
   if j[1] >= threshold:
      k.append(j[0])
   match2.append(",".join(k))
   k = []

# saving matches to df1 
df1['matches'] = match2 
print("\nMatches...")
print(df1)
This will produce the following output −
Dataframe 1 =
       Car
0      BMW
1     Audi
2    Lexus
3 Mercedes
4    Rolls
Dataframe 2 =
           Car
0          BM
1        Audi
2          Le
3    Mercedes
4 Rolls Royce

Matches...
        Car matches
0       BM       BM
1     Audi     Audi
2    Lexus
3 Mercedes MERCEDES
4    Rolls
How to transform List string to upper case in Java?

Let’s first create a List string:
List<String> list = Arrays.asList("David", "Tom", "Ken","Yuvraj", "Gayle");
Now transform the above list to upper case:
list.stream().map(players -> players.toUpperCase())
To display, use forEach():
list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));
The following is an example to transform List string to upper case:
import java.util.Arrays;
import java.util.List;
public class Demo {
   public static void main(final String[] args) {
      List<String> list = Arrays.asList("David", "Tom", "Ken","Yuvraj", "Gayle");
      System.out.print("List = "+list);
      System.out.print("\nUppercase strings = ");
      list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));
   }
}
List = [David, Tom, Ken, Yuvraj, Gayle]
Uppercase strings = DAVID TOM KEN YUVRAJ GAYLE
How to store time created in a MySQL table?

You can use DEFAULT CURRENT_TIMESTAMP. Keep in mind that it will work only at the time of insertion. Let us first create a table −
mysql> create table DemoTable
   (
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Arrivaltime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
   );
Query OK, 0 rows affected (0.31 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(Arrivaltime) values('2018-01-31 10:34:56');
Query OK, 1 row affected (0.06 sec)

mysql> insert into DemoTable values();
Query OK, 1 row affected (0.06 sec)

mysql> insert into DemoTable(Arrivaltime) values('2019-01-31 11:10:12');
Query OK, 1 row affected (0.04 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+---------------------+
| Id | Arrivaltime         |
+----+---------------------+
| 1  | 2018-01-31 10:34:56 |
| 2  | 2019-05-02 12:50:24 |
| 3  | 2019-01-31 11:10:12 |
+----+---------------------+
3 rows in set (0.00 sec)
Finding the smallest value in a JSON object in JavaScript

We are required to write a JavaScript function that takes in a JSON object as one and only argument.
The JSON object has string keys mapped to some numbers. Our function should traverse through the object, find and return the smallest value from the object.
The code for this will be −
const obj = {
   "a": 4,
   "b": 2,
   "c": 5,
   "d": 1,
   "e": 3
};
const findSmallestValue = obj => {
   const smallest = Object.keys(obj).reduce((acc, val) => {
      return Math.min(acc, obj[val]);
   }, Infinity);
   return smallest;
}
console.log(findSmallestValue(obj));
And the output in the console will be −
1
fscanf() function in PHP

The fscanf() function parses input from an open file according to a specified format. It returns the values parsed as an array, if only two parameters were passed.
fscanf(file_pointer, format, mixed)
file_pointer − A file system pointer resource created using fopen().
file_pointer − A file system pointer resource created using fopen().
format − Specify the format. Here are the values:%% - Returns a percent%b - Binary number%c - The character according to the ASCII value%f - Floating-point number%F - Floating-point number%o - Octal number%s - String%d - Signed decimal number%e - Scientific notation%u - Unsigned decimal number%x - Hexadecimal number for lowercase letters%X - Hexadecimal number for uppercase letters
format − Specify the format. Here are the values:
%% - Returns a percent
%b - Binary number
%c - The character according to the ASCII value
%f - Floating-point number
%F - Floating-point number
%o - Octal number
%s - String
%d - Signed decimal number
%e - Scientific notation
%u - Unsigned decimal number
%x - Hexadecimal number for lowercase letters
%X - Hexadecimal number for uppercase letters
mixed − Specify the assigned values. Optional.
mixed − Specify the assigned values. Optional.
The fscanf() function returns the values parsed as an array, if only two parameters were passed.
<?php
   $file_pointer = fopen("new.txt", "r");
   while ($playerrank = fscanf($handle, "%s\t%d\n")) {
      list ($name, $rank) = $playerrank;
      echo “$name got rank $rank.”;
   }
   fclose($file_pointer);
?>
Amit got rank 2
Python Pandas - Getting values from a specific level in Multiindex

To get values from a specific level in Multiindex, use the multiIndex.get_level_values() method in Pandas.
At first, import the required libraries −
import pandas as pd
Create a multi-index. The names parameter sets the names for the levels in the index
multiIndex = pd.MultiIndex.from_arrays([[5, 10], [15, 20], [25, 30], [35, 40]],
   names=['a', 'b', 'c', 'd'])
Get value from specific value. Get 0th level value −
print("\nGet level value (0th level)...\n",multiIndex.get_level_values(0))

Get 1st level value −
print("\nGet level value (1st level)...\n",multiIndex.get_level_values(1))
Following is the code −
import pandas as pd

# Create a multi-index
# The names parameter sets the names for the levels in the index
multiIndex = pd.MultiIndex.from_arrays([[5, 10], [15, 20], [25, 30], [35, 40]],
names=['a', 'b', 'c', 'd'])

print("Multi-index...\n",multiIndex)

# get 0th level value
print("\nGet level value (0th level)...\n",multiIndex.get_level_values(0))

# get 1st level value
print("\nGet level value (1st level)...\n",multiIndex.get_level_values(1))

# dropping a level from the multiindex
print("\nDropping a level...\n",multiIndex.droplevel())
This will produce the following output −
Multi-index...
MultiIndex([( 5, 15, 25, 35),
(10, 20, 30, 40)],
names=['a', 'b', 'c', 'd'])

Get level value (0th level)...
Int64Index([5, 10], dtype='int64', name='a')

Get level value (1st level)...
Int64Index([15, 20], dtype='int64', name='b')

Dropping a level...
MultiIndex([(15, 25, 35),
(20, 30, 40)],
names=['b', 'c', 'd'])
SVG text-decoration Attribute - GeeksforGeeks

31 Mar, 2022
The text-decoration attribute defines whether text is written with a strike-through, overline and/or underline. The main difference between CSS text-decoration property and SVG text-decoration attribute is that, SVG uses the ‘fill‘ and ‘stroke‘ values to paint the text decorations. It has effect only on the following elements <altGlyph>, <text>, <textPath>, <tref>, and <tspan>.
Syntax:
text-decoration = "text-decoration-line" | "text-decoration-style" 
                 | "text-decoration-color"

Attribute Values: The text-decoration attribute accepts the values mentioned above and described below
text-decoration-line: It sets the text-decoration, to line-through or underline.
text-decoration-style: It sets the style of the line used for the decoration, such as solid, wavy, or dashed.
text-decoration-color: It sets the color of the decoration.
Example 1: Below examples illustrate the use of text-decoration attribute.
HTML
<!DOCTYPE html><html>  <body>    <h1 style="color: green; font-size: 40px;">        GeeksforGeeks    </h1>      <p>        Example for text-decoration="underline"    </p>      <svg viewBox="0 0 450 250"         xmlns="http://www.w3.org/2000/svg">                  <text y="20" text-decoration="underline">            GeeksforGeeks        </text>    </svg></body>  </html>
Output:
Example 2:
HTML
<!DOCTYPE html><html>  <body>    <h1 style="color: green; font-size: 40px;">        GeeksforGeeks    </h1>      <p>        Example for text-decoration="line-through"    </p>      <svg viewBox="0 0 450 250"         xmlns="http://www.w3.org/2000/svg">                  <text x="0" y="40"             text-decoration="line-through">            GeeksforGeeks        </text>    </svg></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-SVG
SVG-Attribute
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using jQuery
How to place text on image using HTML and CSS?
How to auto-resize an image to fit a div container using CSS?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Java Examples - Use of savepoint & rollback

How to make a Savepoint & Rollback in java?
Following example uses Rollback method of connection to Rollback to a previously saved SavePoint.
import java.sql.*;

public class jdbcConn {
   public static void main(String[] args) throws Exception {
      Class.forName("org.apache.derby.jdbc.ClientDriver");
      Connection con = DriverManager.getConnection(
         "jdbc:derby://localhost:1527/testDb","name","pass");
      
      Statement stmt = con.createStatement();
      String query1 = "insert into emp values(5,'name','job')";
      String query2 = "select * from emp";
      
      con.setAutoCommit(false);
      Savepoint spt1 = con.setSavepoint("svpt1");
      stmt.execute(query1);
      ResultSet rs = stmt.executeQuery(query2);
      int no_of_rows = 0;
      
      while (rs.next()) {
         no_of_rows++;
      }
      System.out.println("rows before rollback statement = " + no_of_rows);
      con.rollback(spt1);
      con.commit();
      no_of_rows = 0;
      rs = stmt.executeQuery(query2);
      
      while (rs.next()) {
         no_of_rows++;
      }
      System.out.println("rows after rollback statement = " + no_of_rows);
   }
}
The above code sample will produce the following result. The result may vary.
rows before rollback statement = 4
rows after rollback statement = 3

 Print
 Add Notes
 Bookmark this page
Implement your own itoa() in C

In this section we will see how to convert an integer number to a string.
The logic is very simple. Here we will use the sprintf() function. This function is used to print some value or line into a string, but not in the console. This is the only difference between printf() and sprintf(). Here the first argument is the string buffer. where we want to save our data.
Input: User will put some numeric value say 42
Output: This program will return the string equivalent result of that number like “42”
Step 1: Take a number as argument
Step 2: Create an empty string buffer to store result
Step 3: Use sprintf() to convert number to string
Step 4: End
 Live Demo
#include<stdio.h>
char* my_itoa(int number) {
   char str[20]; //create an empty string to store number
   sprintf(str, "%d", number); //make the number into string using sprintf function
   return str;
}
main() {
   int number;
   printf("Enter a number: ");
   scanf("%d", &number);
   printf("You have entered: %s", my_itoa(number));
}
Enter a number: 56
You have entered: 56
Apache Kafka - Tools

Kafka Tool packaged under “org.apache.kafka.tools.*. Tools are categorized into system tools and replication tools.
System tools can be run from the command line using the run class script. The syntax is as follows −
bin/kafka-run-class.sh package.class - - options
Some of the system tools are mentioned below −
Kafka Migration Tool − This tool is used to migrate a broker from one version to an-other.
Kafka Migration Tool − This tool is used to migrate a broker from one version to an-other.
Mirror Maker − This tool is used to provide mirroring of one Kafka cluster to another.
Mirror Maker − This tool is used to provide mirroring of one Kafka cluster to another.
Consumer Offset Checker − This tool displays Consumer Group, Topic, Partitions, Off-set, logSize, Owner for the specified set of Topics and Consumer Group.
Consumer Offset Checker − This tool displays Consumer Group, Topic, Partitions, Off-set, logSize, Owner for the specified set of Topics and Consumer Group.
Kafka replication is a high level design tool. The purpose of adding replication tool is for stronger durability and higher availability. Some of the replication tools are mentioned below −
Create Topic Tool − This creates a topic with a default number of partitions, replication factor and uses Kafka's default scheme to do replica assignment.
Create Topic Tool − This creates a topic with a default number of partitions, replication factor and uses Kafka's default scheme to do replica assignment.
List Topic Tool − This tool lists the information for a given list of topics. If no topics are provided in the command line, the tool queries Zookeeper to get all the topics and lists the information for them. The fields that the tool displays are topic name, partition, leader, replicas, isr.
List Topic Tool − This tool lists the information for a given list of topics. If no topics are provided in the command line, the tool queries Zookeeper to get all the topics and lists the information for them. The fields that the tool displays are topic name, partition, leader, replicas, isr.
Add Partition Tool − Creation of a topic, the number of partitions for topic has to be specified. Later on, more partitions may be needed for the topic, when the volume of the topic will increase. This tool helps to add more partitions for a specific topic and also allows manual replica assignment of the added partitions.
Add Partition Tool − Creation of a topic, the number of partitions for topic has to be specified. Later on, more partitions may be needed for the topic, when the volume of the topic will increase. This tool helps to add more partitions for a specific topic and also allows manual replica assignment of the added partitions.

    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
Bootstrap class dropdown-header

Add a header to label sections of actions in any drop-down menu by using the class dropdown-header.
You can try to run the following code to implement the dropdown-header Bootstrap class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "dropdown">
         <button type = "button" class = "btn dropdown-toggle" id = "dropdownMenu1" data-toggle = "dropdown">
            Diet
            <span class = "caret"></span>
         </button>
         <ul class = "dropdown-menu pull-right" role = "menu" aria-labelledby = "dropdownMenu1">
            <li role = "presentation" class = "dropdown-header">Vegetables</li>
            <li role = "presentation">
               <a role = "menuitem" tabindex = "-1" href = "#">Potato</a>
            </li>
            <li role = "presentation">
               <a role = "menuitem" tabindex = "-1" href = "#">Tomato</a>
            </li>
            <li role = "presentation">
               <a role = "menuitem" tabindex = "-1" href = "#">
                  Brocolli
               </a>
            </li>
            <li role = "presentation" class = "dropdown-header">Fruits</li>
            <li role = "presentation">
               <a role = "menuitem" tabindex = "-1" href = "#">
                  Apple
               </a>
            </li>
            <li role = "presentation">
               <a role = "menuitem" tabindex = "-1" href = "#">
                  Kiwi
               </a>
            </li>
         </ul>
      </div>
   </body>
</html>
How to add tooltip to JLabel in Java?

Tooltip is visible whenever you will place the mouse cursor on the label. Use the setToolTipText() method to add tooltip to JLabel −
label.setToolTipText("This is a demo tooltip");
The following is an example to add tooltip to JLabel −
import java.awt.Color;
import java.awt.Font;
import javax.swing.*;
import javax.swing.border.Border;
public class SwingDemo {
   public static void main(String args[]) {
      JFrame frame = new JFrame("Demo");
      JLabel label;
      label = new JLabel("Demo Label!");
      label.setFont(new Font("Verdana", Font.PLAIN, 14));
      label.setToolTipText("This is a demo tooltip");
      Border border = BorderFactory.createLineBorder(Color.ORANGE);
      label.setBorder(border);
      frame.add(label);
      frame.setSize(500,300);
      frame.setVisible(true);
   }
}
Merge two tables with union in MySQL?

To merge two tables with UNION, you can use create table select statement. Following is the syntax −
create table yourNewTableName
select * from yourFirstTableName
UNION
select * from yourSecondTableName;
Let us first create a table. Following is the query −
mysql> create table FirstTable
   -> (
   -> Id int,
   -> PersonName varchar(20)
   -> );
Query OK, 0 rows affected (2.10 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into FirstTable values(10,'Larry');
Query OK, 1 row affected (0.12 sec)

mysql> insert into FirstTable values(20,'David');
Query OK, 1 row affected (0.22 sec)
Following is the query to display all records from the table using select statement −
mysql> select * from FirstTable;
This will produce the following output −
+------+------------+
| Id   | PersonName |
+------+------------+
| 10   | Larry      |
| 20   | David      |
+------+------------+
2 rows in set (0.00 sec)
Following is the query to create the second table −
mysql> create table SecondTable
   -> (
   -> Id int,
   -> PersonName varchar(20)
   -> );
Query OK, 0 rows affected (0.91 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into SecondTable values(30,'Chris');
Query OK, 1 row affected (0.17 sec)

mysql> insert into SecondTable values(40,'Robert');
Query OK, 1 row affected (0.15 sec)
Let us now display all records from the table using the select statement −
mysql> select *from SecondTable;
This will produce the following output −
+------+------------+
| Id   | PersonName |
+------+------------+
| 30   | Chris      |
| 40   | Robert     |
+------+------------+
2 rows in set (0.00 sec)
Now, create a table from merging two tables (FirstTable + SecondTable) with union −
mysql> create table MergeBothTableDemo
   -> select * from FirstTable
   -> UNION
   -> select * from SecondTable;
Query OK, 4 rows affected (0.86 sec)
Records: 4 Duplicates: 0 Warnings: 0
Let us check the new table records. Following is the query −
mysql> select * from MergeBothTableDemo;
This will produce the following output −
+------+------------+
| Id   | PersonName |
+------+------------+
| 10   | Larry      |
| 20   | David      |
| 30   | Chris      |
| 40   | Robert     |
+------+------------+
4 rows in set (0.00 sec)