code-rag-bench/online-tutorials huggingface dataset:
MySQL query to find a list of city names that do not start with vowels?

You can use DISTINCT with RLIKE operator to find a list of city names that do not start with vowels.
The syntax is as follows −
SELECT DISTINCT yourCityColumnName FROM yourTableName WHERE
yourCityColumnName NOT RLIKE ‘ ^[AEIOUaeiou].*$’;
To understand the above syntax, let us create a table. Here, we have a column for city names.
The query to create a table is as follows −
mysql> create table Employee_Information
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> EmployeeName varchar(20),
   -> CityName varchar(20),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.76 sec)
Insert some records in the table using INSERT command. The query is as follows −
mysql> insert into Employee_Information(EmployeeName,CityName) values('Larry','New York');
Query OK, 1 row affected (0.12 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('Sam','Indianapolis');
Query OK, 1 row affected (0.15 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('Carol','El Paso');
Query OK, 1 row affected (0.16 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('John','Austin');
Query OK, 1 row affected (0.07 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('Mike','Denver');
Query OK, 1 row affected (0.06 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('David','Las Vegas');
Query OK, 1 row affected (0.11 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('James','Albuquerque');
Query OK, 1 row affected (0.13 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('Robert','Portland');
Query OK, 1 row affected (0.28 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('Richard','Irvine');
Query OK, 1 row affected (0.10 sec)

mysql> insert into Employee_Information(EmployeeName,CityName) values('Michael',' Garland');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from Employee_Information;
The following is the output −
+----+--------------+--------------+
| Id | EmployeeName | CityName     |
+----+--------------+--------------+
|  1 | Larry        | New York     |
|  2 | Sam          | Indianapolis |
|  3 | Carol        | El Paso      |
|  4 | John         | Austin       |
|  5 | Mike         | Denver       |
|  6 | David        | Las Vegas    |
|  7 | James        | Albuquerque  |
|  8 | Robert       | Portland     |
|  9 | Richard      | Irvine       |
| 10 | Michael      | Garland      |
+----+--------------+--------------+
10 rows in set (0.00 sec)
Here is the query to find a list of city names that do not start with vowel. This means first letter of city name must not start with A,E,I,O,U or a,e,i,o,u −
mysql> SELECT DISTINCT CityName FROM Employee_Information
   -> WHERE CityName NOT RLIKE '^[AEIOUaeiou].*$';
The following is the output −
+-----------+
| CityName  |
+-----------+
| New York  |
| Denver    |
| Las Vegas |
| Portland  |
| Garland   |
+-----------+
5 rows in set (0.00 sec)
How To Concatenate Two or More Pandas DataFrames? - GeeksforGeeks

05 Jun, 2021
Let’s understand how we can concatenate two or more Data Frames. A concatenation of two or more data frames can be done using pandas.concat() method. concat() in pandas works by combining Data Frames across rows or columns. We can concat two or more data frames either along rows  (axis=0) or along columns (axis=1)
Step 1: Import numpy and pandas libraries.
Python3
import pandas as pdimport numpy as np
Step 2: Create two Data Frames which we will be concatenating now. For creating Data frames we will be using numpy and pandas.
Python3
df1 = pd.DataFrame(np.random.randint(25, size=(4, 4)),                   index=["1", "2", "3", "4"],                   columns=["A", "B", "C", "D"]) df2 = pd.DataFrame(np.random.randint(25, size=(6, 4)),                   index=["5", "6", "7", "8", "9", "10"],                   columns=["A", "B", "C", "D"]) df3 = pd.DataFrame(np.random.randint(25, size=(4, 4)),                   columns=["A", "B", "C", "D"]) df4 = pd.DataFrame(np.random.randint(25, size=(4, 4)),                   columns=["E", "F", "G", "H"]) display(df1, df2, df3, df4)
 
 
Output:
 
 
Step 3: Now we need to pass the two data frames to the contact() method in the form of a list and mention in which axis you want to concat.
 
Python3
# concatenating df1 and df2 along rowsvertical_concat = pd.concat([df1, df2], axis=0) # concatenating df3 and df4 along columnshorizontal_concat = pd.concat([df3, df4], axis=1) display(vertical_concat, horizontal_concat)
 
 
Output:
 
 
anikaseth98
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Python Classes and Objects
Create a directory in Python
Hive - Drop Table

This chapter describes how to drop a table in Hive. When you drop a table from Hive Metastore, it removes the table/column data and their metadata. It can be a normal table (stored in Metastore) or an external table (stored in local file system); Hive treats both in the same manner, irrespective of their types.
The syntax is as follows:
DROP TABLE [IF EXISTS] table_name;
The following query drops a table named employee:
hive> DROP TABLE IF EXISTS employee;
On successful execution of the query, you get to see the following response:
OK
Time taken: 5.3 seconds
hive>
The following JDBC program drops the employee table.
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveDropTable {

   private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
   
   public static void main(String[] args) throws SQLException {
   
      // Register driver and create driver instance
      Class.forName(driverName);

      // get connection
      Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/userdb", "", "");

      // create statement
      Statement stmt = con.createStatement();

      // execute statement
      stmt.executeQuery("DROP TABLE IF EXISTS employee;");
      System.out.println("Drop table successful.");
      
      con.close();
   }
}
Save the program in a file named HiveDropTable.java. Use the following commands to compile and execute this program.
$ javac HiveDropTable.java
$ java HiveDropTable
Drop table successful

The following query is used to verify the list of tables:
hive> SHOW TABLES;
emp
ok
Time taken: 2.1 seconds
hive>

    50 Lectures 
     4 hours 

 Navdeep Kaur

    67 Lectures 
     4 hours 

 Bigdata Engineer

    109 Lectures 
     2 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
What is the lifetime of JavaScript variables?

The lifetime of a JavaScript variable begins when it is declared −
var rank;
A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.The completion of a function deletes the local variable.
A global variable has a global scope which means it can be defined anywhere in your JavaScript code. Global variables delete when the web browser is closed. However if a new page is loaded in the same browser window, then it remains.
Here’s the usage of global variables −
You can try to run the following code to learn how to work with a scope of variables in JavaScript
Live Demo
<html>
   <body onload = checkscope();>
      <script>
         <!--
         var myVar = "global";   // Declare a global variable
         function checkscope( ) {
            var myVar = "local"; // Declare a local variable
            document.write(myVar);
         }
         //-->
      </script>
   </body>
</html>
Difference between alert box and prompt box in JavaScript - GeeksforGeeks

19 Apr, 2022
1. Alert box : An alert box is one type of popup boxes in JavaScript which is often used to make sure that information have come through the user. So, the user will have to click “OK” to proceed when an alert box pops up on the window. 
Syntax :
window.alert("message");
Another syntax to use alert box is :
alert("message");
2. Prompt box : It is also one of the type of popup boxes in JavaScript which is often to take input a value before entering a page from the user. To proceed after entering an input value in the prompt, the user will have to click either “OK” or “Cancel”. 
Syntax :
window.prompt("some message");
Another syntax to use alert box is :
prompt("some message");
Below example illustrates the differences between alert box and prompt box : Example : 
HTML
<!DOCTYPE HTML><html> <head>    <title>        Alert Box vs Prompt Box    </title></head> <body style="text-align:center;" id="body">     <h1 style="color:green;">        GeeksforGeeks    </h1>         <button onclick="alertBox()">        Show Alert Box    </button>    <button onclick="promptBox()">        Show Prompt Box    </button>         <script>        function alertBox(){            alert("GeeksforGeeks: This" +                    " is an Alert Box.");        }         function promptBox(){            prompt("Enter your Name:");        }    </script></body> </html>                    
Output: 
Before clicking the button :
  
After clicking the Show Alert Box button :
  
After clicking the Show Prompt Box button : 
 
Supported Browsers: The list of browser supported by prompt() and alert() box are listed below :
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Let us see the differences in a tabular form -: 
Its syntax is -:
window.alert(“sometext”);
Its syntax is -:
window.prompt(“sometext”,”defaultText”);
Difference Between
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference between Internal and External fragmentation
Difference between Prim's and Kruskal's algorithm for MST
Differences and Applications of List, Tuple, Set and Dictionary in Python
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
Differences between Functional Components and Class Components in React
Convert a string to an integer in JavaScript
File uploading in React.js
Python program to convert XML to Dictionary

14 Sep, 2021
In this article, we will discuss how to convert an XML to a dictionary using Python.
xmltodict: It is a Python module that makes working with XML feel like you are working with [JSON]. Run the following command in the terminal to install the module.
Syntax:
pip install xmltodict
pprint: The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a well-formatted and more readable way.
Import necessary module to working space.
Open the XML File in Read-only mode and read the contents using file.read() and store it in a variable.
Syntax:
with open('filename', 'r', encoding='utf-8') as file:
    my_xml = file.read()
Use xmltodict.parse() to parse the content from the variable and convert it into Dictionary.
Syntax : 
xmltodict.parse(xml_input, encoding=’utf-8′, expat=expat, process_namespaces=False, namespace_separator=’:’, **kwargs) 
Use pprint(pretty print) to print the dictionary in well-formatted and readable way.
Syntax : 
pprint.pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True)
Example: Converting XML to dictionary
File Used:
Python3
# Import the required modulesimport xmltodictimport pprint  # Open the file and read the contentswith open('example.xml', 'r', encoding='utf-8') as file:    my_xml = file.read()  # Use xmltodict to parse and convert # the XML documentmy_dict = xmltodict.parse(my_xml)  # Print the dictionarypprint.pprint(my_dict, indent=2)
Output:
Example 2: Converting XML to dictionary
File Used:
Python3
# Import the required modulesimport xmltodictimport pprint  # Open the file and read the contentswith open('example_2.xml', 'r', encoding='utf-8') as file:    my_xml = file.read()  # Use xmltodict to parse and convert the # XML documentmy_dict = xmltodict.parse(my_xml)  # Print the dictionarypprint.pprint(my_dict, indent=2)
Output:
Blogathon-2021
Picked
Python-XML
Blogathon
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C program to Compare Two Strings without using strcmp() function

06 Sep, 2021
Given two strings s1 and s2, the task is to write C program compare the two strings without using strcmp() function. If string are equal then print “Equal strings” else print “Unequal strings”.
Examples:
Input: s1 = “geeksforgeeks”, s2 = “geeks”Output: Unequal Strings
Input: s1 = “geeksforgeeks”, s2 = “geeksforgeeks”Output: Equal Strings
Approach: There are three possible cases occur when we compare two strings:
Both the strings are the same means difference of ASCII value between both the strings is 0.Both the strings are different means ASCII value of first not matching character in the first string is less than the second string then the difference between both the strings is (<0).Both the strings are different means ASCII value of first not matching character in the first string is greater than the second string then the difference between both the strings is (>0).
Both the strings are the same means difference of ASCII value between both the strings is 0.
Both the strings are different means ASCII value of first not matching character in the first string is less than the second string then the difference between both the strings is (<0).
Both the strings are different means ASCII value of first not matching character in the first string is greater than the second string then the difference between both the strings is (>0).
Based on the above three conditions, the idea is to compare each character of the given strings one by one whenever condition 2 or 3 occurs then print “Unequal strings” else print “Equal strings”.
Below is the implementation of the above approach:
C
// C program to compare the two strings// without using strcmp() function#include <stdio.h> // Function that compares the two stringvoid compareStrings(char* x, char* y){    int flag = 0;     // Iterate a loop till the end    // of both the strings    while (*x != '\0' || *y != '\0') {        if (*x == *y) {            x++;            y++;        }         // If two characters are not same        // print the difference and exit        else if ((*x == '\0' && *y != '\0')                 || (*x != '\0' && *y == '\0')                 || *x != *y) {            flag = 1;            printf("Unequal Strings\n");            break;        }    }     // If two strings are exactly same    if (flag == 0) {        printf("Equal Strings\n");    }} // Driver Codeint main(void){    // Given strings s1 and s2    char s1[20] = "python";    char s2[20] = "dsa";     // Function Call    compareStrings(s1, s2);    return 0;}
Unequal Strings
Time Complexity: O(N)Auxiliary Space: O(1)
varshagumber28
C Programs
Greedy
Mathematical
School Programming
Strings
Strings
Greedy
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.get_values()

13 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.get_values() function return an ndarray containing the underlying data of the given series object.
Syntax: Series.get_values()
Parameter : None
Returns : ndarray
Example #1: Use Series.get_values() function to return an array containing the underlying data of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 25, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.get_values() function to return the underlying data of the given series object as an array.
# return an arrayresult = sr.get_values()  # Print the resultprint(result)
Output :
As we can see in the output, the Series.get_values() function has returned the given series object as an array. Example #2 : Use Series.get_values() function to return an array containing the underlying data of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([11, 21, 8, 18, 65, 84, 32, 10, 5, 24, 32])  # Create the Indexindex_ = pd.date_range('2010-10-09', periods = 11, freq ='M')  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.get_values() function to return the underlying data of the given series object as an array.
# return an arrayresult = sr.get_values()  # Print the resultprint(result)
Output :As we can see in the output, the Series.get_values() function has returned the given series object as an array.
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.
How to transform Vector into String?

06 Jul, 2017
Vectors: Vectors are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. C++ program to transform vector into string.String: C++ has in its definition a way to represent sequence of characters as an object of class. This class is called std:: string.
std::ostringstream: It is an Output stream class to operate on strings. Objects of this class use a string buffer that contains a sequence of characters. This sequence of characters can be accessed directly as a string object, using member str.
// C++ program transform a vector into// a string.#include <vector>#include <string>#include <algorithm>#include <sstream>#include <iterator>#include <iostream>  int main(){  std::vector<int> vec;  vec.push_back(1);  vec.push_back(2);  vec.push_back(3);  vec.push_back(4);  vec.push_back(5);  vec.push_back(6);    std::ostringstream vts;    if (!vec.empty())  {    // Convert all but the last element to avoid a trailing ","    std::copy(vec.begin(), vec.end()-1,        std::ostream_iterator<int>(vts, ", "));      // Now add the last element with no delimiter    vts << vec.back();  }    std::cout << vts.str() << std::endl;}
Output:
1, 2, 3, 4, 5, 6

This article is contributed by Jatin Goyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-algorithm-library
cpp-strings-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How do I plot multiple X or Y axes in Matplotlib?

To plot multiple X or Y axis, we can use twinx() or twiny() methods, we can take the following Steps −
Using subplots() method, create a figure and a set of subplots.
Using subplots() method, create a figure and a set of subplots.
Plot [1, 2, 3, 4, 5] data points on the left Y-axis scales.
Plot [1, 2, 3, 4, 5] data points on the left Y-axis scales.
Using twinx() method, create a twin of Axes with a shared X-axis but independent Y-axis, ax2.
Using twinx() method, create a twin of Axes with a shared X-axis but independent Y-axis, ax2.
Plot [11, 12, 31, 41, 15] data points on the right Y-axis scale, with blue color.
Plot [11, 12, 31, 41, 15] data points on the right Y-axis scale, with blue color.
Using tight_layout() method, adjust the padding between and around the subplots.
Using tight_layout() method, adjust the padding between and around the subplots.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, ax1 = plt.subplots()
ax1.plot([1, 2, 3, 4, 5], color='red')
ax2 = ax1.twinx()
ax2.plot([11, 12, 31, 41, 15], color='blue')
fig.tight_layout()
plt.show()
Node.js prompt.get() Method - GeeksforGeeks

15 Oct, 2020
The prompt.get() method is an asynchronous function. This method takes strings representing property names in addition to objects for complex property validation (and more). This function is used for I/O operations.
Syntax:
prompt.get([object]/[properties name], callbackfunction)

Parameters: This method takes two parameters as shown below:
[object]/[properties name]: This parameter holds the property of the input value or predefined object.callbackfunction: This parameter holds the callback function to make this function an asynchronous function.
[object]/[properties name]: This parameter holds the property of the input value or predefined object.
callbackfunction: This parameter holds the callback function to make this function an asynchronous function.
Installation Module:
You can visit the link to Install this module. You can install this package by using this command.npm install prompt
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js

You can visit the link to Install this module. You can install this package by using this command.npm install prompt

npm install prompt

After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js

node index.js

Filename: Index.js
var prompt = require('prompt');  // Function callprompt.start();    // Reading two properties from user ie. name & classprompt.get(['Name', 'class'], function (err, result) {        // Printing the result  console.log('Command-line input received:');  console.log('Name: ' + result.name);  console.log('class: ' + result.class);})
Project Structure:
Run the index.js file using the following command:
node index.js
Output:
prompt: name: some-user
prompt: class: 12th
Command-line input received:
name: some-user
class: 12th

Node.js-Methods
Node.js
Web Technologies
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to build a basic CRUD app with Node.js and ReactJS ?
How to connect Node.js with React.js ?
Mongoose Populate() Method
Express.js req.params Property
Mongoose find() Function
Top 10 Front End Developer Skills That You Need in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
C | Pointer Basics | Question 1 - GeeksforGeeks

04 Feb, 2013
What is the output of following program?
# include <stdio.h>void fun(int x){    x = 30;}  int main(){  int y = 20;  fun(y);  printf("%d", y);  return 0;}
(A) 30(B) 20(C) Compiler Error(D) Runtime ErrorAnswer: (B)Explanation: Parameters are always passed by value in C. Therefore, in the above code, value of y is not modified using the function fun(). So how do we modify the value of a local variable of a function inside another function. Pointer is the solution to such problems. Using pointers, we can modify a local variable of a function inside another function. See the next question.Note that everything is passed by value in C. We only get the effect of pass by reference using pointers.
C-Pointers
Pointers
C Language
C Quiz
Pointers
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Multithreading in C
Exception Handling in C++
Arrow operator -> in C/C++ with Examples
'this' pointer in C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Structure & Union | Question 10
Output of C programs | Set 64 (Pointers)
C | Misc | Question 7
How to find length of a string without string.h and loop in C? - GeeksforGeeks

26 Oct, 2020
Find the length of a string without using any loops and string.h in C. Your program is supposed to behave in following way: 
Enter a string: GeeksforGeeks (Say user enters GeeksforGeeks)
Entered string is: GeeksforGeeks
Length is: 13


You may assume that the length of entered string is always less than 100.The following is the solution. 
C
#include <stdio.h>int main(){         // entered string    char ch[50] = "GeeksforGeeks";       // printing entered string    printf("Entered String is:");       // returns length of string    // along printing string    int len        = printf("%s\n", ch);       printf("Length is:");       // printing length    printf("%d", len - 1);}
Entered String is:GeeksforGeeks
Length is:13

The idea is to use return values of printf(). printf() returns the number of characters successfully written on output.In the above program we just use the property of printf() as it returns the number of characters entered in the array string.  
Another way of finding the length of a string without using string.h or loops is Recursion. The following program does the work of finding a length of a string using recursion.  
C
// C program for the above approach#include <stdio.h> void LengthofString(int n,char *string){    if(string[n] == '\0')    {        printf("%i",n);        return;    }         LengthofString(n+1,string);    //printf("%c",string[n]);} int main(){    char string[100];    printf("Give a string : \n");    scanf("%s",string);    printf("Entered string is:%s\n", string);    LengthofString(0,string);         return 0;}
Give a string : 
Entered string is:0
1

The Function LengthofString calls itself until the character of string is’nt a null character it calls itself, when it calls itself it increases the value of the variable ‘n’ which stores number of times the function has been called and when it encounters the null character the function prints the value of ‘n’ and returns back in the same direction in which it was executed.This article is contributed by Sumit Singh Chauhan. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Zeeking99
sc047108
C-String
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Multithreading in C
Exception Handling in C++
Arrow operator -> in C/C++ with Examples
'this' pointer in C++
UDP Server-Client implementation in C
Understanding "extern" keyword in C
Smart Pointers in C++ and How to Use Them
Sorting Vector of Pairs in C++ | Set 1 (Sort by first and second)
Multiple Inheritance in C++
How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?

To plot two Pandas time series on the sameplot with legends and secondary Y-axis, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create a one-dimensional ndarray with axis labels (including time series).
Create a one-dimensional ndarray with axis labels (including time series).
Make a dataframe with some column list.
Make a dataframe with some column list.
Plot columns A and B using dataframe plot() method.
Plot columns A and B using dataframe plot() method.
Return the handles and labels for the legend using get_legend_handles_labels() method.
Return the handles and labels for the legend using get_legend_handles_labels() method.
Place a legend on the figure using legend() method.
Place a legend on the figure using legend() method.
To display the figure, use show() method.
To display the figure, use show() method.
import pandas as pd
from matplotlib import pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

ts = pd.Series(np.random.randn(10), index=pd.date_range('2021-04-10', periods=10))

df = pd.DataFrame(np.random.randn(10, 4), index=ts.index, columns=list('ABCD'))

ax1 = df.A.plot(color='red', label='Count')
ax2 = df.B.plot(color='yellow', secondary_y=True, label='Sum')

h1, l1 = ax1.get_legend_handles_labels()
h2, l2 = ax2.get_legend_handles_labels()

plt.legend(h1+h2, l1+l2, loc=2)

plt.show()
How to retrieve GET parameters from JavaScript ? - GeeksforGeeks

31 Dec, 2020
In order to know the parameters, those are passed by the “GET” method, like sometimes we pass the Email-id, Password, and other details. For that purpose, We are using the following snippet of code.
When you visit any website, ever thought what the question mark ‘?’ is doing in the address bar. Let’s find out what is the use of this question mark ‘?’.
What is the ‘?’:
The question mark acts like a separator and what follows after is a query string which is in the form of key value pairs. Multiple key value pairs are separated by the ‘&’ symbol.
Example:
geeksforgeeks.org/web-development?page=2&name=gfg
The above picture shows the address. The content followed by the ‘?’ is the query string which has two key-value pairs which are shown below :
Pair 1: page = 2
Pair 2: name = gfg
Our task is to get the respective values from each pair which are also known as GET parameters.
Method 1: Using the keys specified in the address: The class URLSearchParams takes in the address of the website and searches for value associated with the key provided.
Here is the code for the above approach:
Javascript
// Arrow function to get the parameter// of the specified keygetParameter = (key) => {      // Address of the current window    address = window.location.search      // Returns a URLSearchParams object instance    parameterList = new URLSearchParams(address)      // Returning the respected value associated    // with the provided key    return parameterList.get(key)}  // Gets the value associated with the key "ie"console.log(getParameter("ie"))
Output:
2
Method 2: Using the forEach property of the URLSearchParams class to retrieve all the GET parameters.
Javascript
// Arrow function to get all the GET parametersgetParameters = () => {      // Address of the current window    address = window.location.search      // Returns a URLSearchParams object instance    parameterList = new URLSearchParams(address)      // Created a map which holds key value pairs    let map = new Map()      // Storing every key value pair in the map    parameterList.forEach((value, key) => {        map.set(key, value)    })      // Returning the map of GET parameters    return map}  // Gets all the getParametersconsole.log(getParameters())
Output:
{"page" => "2", "name" => "gfg"}
JavaScript-Misc
Picked
Technical Scripter 2020
JavaScript
Technical Scripter
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
How to get selected value in dropdown list using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
List down the name of the Web drivers supported by Selenium.

The name of the web drivers supported by Selenium are listed below −
Google Chrome Driver [ ChromeDriver() supports chrome ]
Google Chrome Driver [ ChromeDriver() supports chrome ]
HTML Unit Driver [ WebClient() supports chrome, firefox and IE ]
HTML Unit Driver [ WebClient() supports chrome, firefox and IE ]
Safari Driver [ SafariDriver() supports Safari ]
Safari Driver [ SafariDriver() supports Safari ]
IOS Driver [ IOSDriver() supports ios ]
IOS Driver [ IOSDriver() supports ios ]
Android Driver [ AndroidDriver() supports Android ]
Android Driver [ AndroidDriver() supports Android ]
OperaChromium Driver [ ChromeDriver() supports opera ]
OperaChromium Driver [ ChromeDriver() supports opera ]
Gecko Driver [ FirefoxDriver() supports firefox ]
Gecko Driver [ FirefoxDriver() supports firefox ]
Microsoft WebDriver [ InternetExplorerDriver() supports IE ]
Microsoft WebDriver [ InternetExplorerDriver() supports IE ]
EventFiring WebDriver [ EventFiring Driver() supports majority of browsers ]
EventFiring WebDriver [ EventFiring Driver() supports majority of browsers ]
Code Implementation with Firefox driver
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class BrowserDriverScript {
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver",       "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      // working with Firefox driver
      WebDriver driver = new FirefoxDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
      System.out.println("Launching the url");
      driver.quit();
   }
}
How to remove the first character of string in PHP?

31 Jul, 2021
Remove the very first character of a given string in PHP
Examples:
Input : Geeksforgeeks
Output : eeksforgeeks

Input :, Hello geek!
Output : Hello geek!

Explanation:In PHP to remove characters from beginning we can use ltrim but in that we have to define what we want to remove from a string i.e. removing characters are to be known.Example:
<?php    $str = "geeks";      // Or we can write ltrim($str, $str[0]);    $str = ltrim($str, 'g');      echo $str;?>
eeks

If string is not known and we want to remove characters from beginning then we can use substr(). Here we can use it by two parameters one is the string and the other is the index. substr() return string from the second parameter index to the end of the string.
<?php    $str = "geeks";    $str1 = substr($str, 1);    echo $str1."\n";    $str1 = substr($str, 2);    echo $str1; ?>
eeks
eks

PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
PHP-string
Picked
Technical Scripter 2018
PHP
Technical Scripter
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to receive JSON POST with PHP ?
Split a comma delimited string into an array in PHP
Download file from URL using PHP
Removing Array Element and Re-Indexing in PHP
How to pass JavaScript variables to PHP ?
How to fetch data from localserver database and display on HTML table using PHP ?
How to Encrypt and Decrypt a PHP String ?
Python | Finding relative order of elements in list

20 Mar, 2019
Sometimes we have an unsorted list an we wish to find the actual position the elements could be when they would be sorted, i.e we wish to construct the list which could give the position to each element destined if the list was sorted. This has a good application in web development and competitive programming domain. Let’s discuss certain ways in which this can be done.
Method #1 : Using sorted() + index() + list comprehensionAll the above function can combine to achieve this particular task. The sorted function returns the sorted order and the indexing is done by the index function. List comprehension does the task of doing for whole list elements and integrating both tasks.
# Python3 code to demonstrate# Finding relative order of elements in list# using sorted() + index() + list comprehension  # initializing listtest_list = [6, 3, 1, 2, 5, 4]  # printing original listprint("The original list is : " + str(test_list))  # using sorted() + index() + list comprehension# Finding relative order of elements in listtemp = sorted(test_list)    res = [temp.index(i) for i in test_list]  # printing resultprint ("The relative ordering list is : " + str(res))
The original list is : [6, 3, 1, 2, 5, 4]
The relative ordering list is : [5, 2, 0, 1, 4, 3]

 
Method #2 : Using map() + enumerate() + dictionary comprehension + sorted()The dictionary comprehension is used in place of list comprehension and the sorted list is formed and the index of actual ordering in sorted list are traversed using enumerate to have key-value pair and then are get by map for all the indices in list.
# Python3 code to demonstrate# Finding relative order of elements in list# using map() + enumerate() + dictionary comprehension + sorted()  # initializing listtest_list = [6, 3, 1, 2, 5, 4]  # printing original listprint("The original list is : " + str(test_list))  # using map() + enumerate() + dictionary comprehension + sorted()# Finding relative order of elements in listtemp = {val: key for key, val in enumerate(sorted(test_list))}res = list(map(temp.get, test_list))  # printing resultprint ("The relative ordering list is : " + str(res))
The original list is : [6, 3, 1, 2, 5, 4]
The relative ordering list is : [5, 2, 0, 1, 4, 3]

Python list-programs
Python
Python Programs
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
How to Plot List of X, Y Coordinates in Matplotlib?

17 Dec, 2020
Prerequisites: 
Matplotlib 
numpy 
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. To plot any data the most basic step starts with creating or loading it, this article discusses all the ways of passing the data to be plotted as list. While passing data as list one important thing to be kept in mind is to keep X,Y Lists of the same size, otherwise it will raise a ValueError. 
Examples shown in this article use scatter plot, the same approaches can be applied to any other type of graph.
In this method, the coordinates are simply passed as two lists.
Approach
Import module
Create a list for X coordinates
Create a list for Y coordinate
Pass these two lists to plot the function
Example: 
Python3
import matplotlib.pyplot as plt  x = [1, 2, 3, 4, 5, 6, 7, 8]y = [2, 3, 1, 3, 1, 4, 2, 3]  plt.scatter(x, y)plt.show()
Output:
Function used: arrange()
Syntax: np.arange(start,end,step)
Parameters:
Start: starting value
End: ending value
Step: step size, by default it is 1.
Approach
Import module
Create numpy array for coordinates
Pass these arrays to plot
Example:
Python3
# importing Matplotlib and Numpy Packagesimport numpy as npimport matplotlib.pyplot as plt  # generating two arrays from 10 to 1 and from 1 to 10x = np.arange(1, 11, 1)  y = np.arange(10, 0, -1)    # plot our list in X,Y coordinatesplt.scatter(x, y)plt.show()
Output:
Creating lists of list of all points to be plotted can also one of the ways of achieving our requirement. After creating such a list it cannot be directly passed to plot, first a transpose needs to taken to get x and y coordinates.
Approach
Import module
Create list of lists for coordinates
Take transpose
Pass the coordinates to the plot
Example
Python3
# importing Matplotlib and Numpy Packagesimport numpy as npimport matplotlib.pyplot as plt  # The data are given as list of lists (2d list)data = np.array([    [1, 4],    [2, 2],    [3, 7],    [4, 6],    [5, 0],    [6, 3]])# Taking transposex, y = data.T    # plot our list in X,Y coordinatesplt.scatter(x, y)plt.show()
Output: 
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use DataGrid Component in ReactJS ?

13 Apr, 2021
A DataGrid Component helps in displaying the information in a grid-like format of rows and columns. Material UI for React has this component available for us, and it is very easy to integrate. We can use the following approach in ReactJS to use DataGrid Component.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:npx create-react-app foldername
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:cd foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui module using the following command:npm install @material-ui/data-grid
Step 3: After creating the ReactJS application, Install the material-ui module using the following command:
npm install @material-ui/data-grid
Project Structure: It will look like the following.
Project Structure
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import * as React from 'react';import { DataGrid } from '@material-ui/data-grid';  const columns = [  { field: 'id', headerName: 'ID', width: 170 },  { field: 'name', headerName: 'NAME', width: 170 },  { field: 'age', headerName: 'AGE', width: 170 },];  const rows = [  { id: 1, name: 'Gourav', age: 12 },  { id: 2, name: 'Geek', age: 43 },  { id: 3, name: 'Pranav', age: 41 },];  export default function App() {  return (    <div style={{ height: 500, width: '80%' }}>      <h4>How to use DataGrid Component in ReactJS?</h4>      <DataGrid rows={rows} columns={columns} pageSize={2} />    </div>  );}
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Reference: https://material-ui.com/components/data-grid/
Material-UI
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python PIL | Image.open() method

17 Jul, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
PIL.Image.open() Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the load() method). See new().
Syntax: PIL.Image.open(fp, mode=’r’)
Parameters:
fp – A filename (string), pathlib.Path object or a file object. The file object must implement read(), seek(), and tell() methods, and be opened in binary mode.mode – The mode. If given, this argument must be “r”.
Returns type: An image object.Raises: IOError – If the file cannot be found, or the image cannot be opened and identified.
Image Used:
     # Imports PIL module from PIL import Image  # open method used to open different extension image fileim = Image.open(r"C:\Users\System-Pc\Desktop\ybear.jpg")   # This method will show image in any image viewer im.show() 
Output:.JPG extension image open.
Another Example: Here we used .PNG extension file.
Image Used:
     # Imports PIL module from PIL import Image  # open method used to open different extension image fileim = Image.open(r"C:\Users\System-Pc\Desktop\lion.png")   # This method will show image in any image viewer im.show() 
Output:.PNG extension image open.
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | Program to write data in a text File

19 Feb, 2019
Pre-requisite: How to import a library in JavaScript. Read from here: https://www.geeksforgeeks.org/javascript-importing-and-exporting-modules/ .
There is a built-in Module or in-built library in NodeJs which handles all the writing operations called fs (File-System). It is basically a JavaScript program (fs.js) where function for writing operations is written. Import fs-module in the program and use functions to write text to files in the system. The following function will create a new file with a given name if there isn’t one, else it will rewrite the file erasing all the previous data in it.
Used Function: The writeFile() functions is used for writing operation.
Syntax:
writeFile( Path, Data, Callback)
Parameters: This method accepts three parameters as mentioned above and described below:
Path: It takes in relative path from the program to the text File. If the file is to be created in the same folder as that of the program, then give the name of the file only. If file not exists then new file will be created automatically.
Data: This argument takes in data which need to write in the file.
Callback Function: It is the callback function which further has an argument (err). If the operation fails to write the data, err shows the fault.
Example:
<script>// Requiring fs module in which// writeFile function is defined.const fs = require('fs')  // Data which will write in a file.let data = "Learning how to write in a file."  // Write data in 'Output.txt' .fs.writeFile('Output.txt', data, (err) => {          // In case of a error throw err.    if (err) throw err;})</script>
Output:
Learning how to write in a file.
Note: Above script can be run using NodeJs interpreter in terminal.
JavaScript-Misc
Technical Scripter 2018
JavaScript
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.