code-rag-bench/online-tutorials huggingface dataset:
Hashtable clear() Method in Java

28 Jun, 2018
The java.util.Hashtable.clear() method in Java is used to clear and remove all of the keys from a specified Hashtable.
Syntax:
Hash_table.clear()
Parameters: The method does not accept any parameters.
Return Value: The method does not return any value.
Below programs are used to illustrate the working of java.util.Hashtable.clear() Method:Program 1:
// Java code to illustrate the clear() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<Integer, String> hash_table = new Hashtable<Integer, String>();          // Inserting Values into table        hash_table.put(10, "Geeks");        hash_table.put(15, "4");        hash_table.put(20, "Geeks");        hash_table.put(25, "Welcomes");        hash_table.put(30, "You");          // Displaying the Hashtable        System.out.println("The Hashtable is: " + hash_table);          // Clearing the hash table using clear()        hash_table.clear();          // Displaying the final Hashtable        System.out.println("Finally the table looks like this: " + hash_table);    }}
The Hashtable is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
Finally the table looks like this: {}

Program 2:
// Java code to illustrate the clear() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<String, Integer> hash_table = new Hashtable<String, Integer>();          // Inserting Values into table        hash_table.put("Geeks", 10);        hash_table.put("4", 15);        hash_table.put("Geeks", 20);        hash_table.put("Welcomes", 25);        hash_table.put("You", 30);          // Displaying the Hashtable        System.out.println("The Hashtable is: " + hash_table);          // Clearing the hash table using clear()        hash_table.clear();          // Displaying the final Hashtable        System.out.println("Finally the table looks like this: " + hash_table);    }}
The Hashtable is: {You=30, Welcomes=25, 4=15, Geeks=20}
Finally the table looks like this: {}

Note: The same operation can be performed with any type of variation and combination of different data types.
Java - util package
Java-Collections
Java-HashTable
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perform MySQL delete under safe mode?

To delete under safe mode, you can use the below query −
SET SQL_SAFE_UPDATES = 0;
To understand the above query, let us create a table. The following is the query to create a table −
mysql> create table SafeDeleteDemo
   −> (
   −> Price int
   −> );
Query OK, 0 rows affected (0.50 sec)
Insert some records in the table with the help of insert command. The query is as follows −
mysql> insert into SafeDeleteDemo values(100);
Query OK, 1 row affected (0.11 sec)

mysql> insert into SafeDeleteDemo values(200);
Query OK, 1 row affected (0.19 sec)

mysql> insert into SafeDeleteDemo values(300);
Query OK, 1 row affected (0.09 sec)

mysql> insert into SafeDeleteDemo values(500);
Query OK, 1 row affected (0.14 sec)

mysql> insert into SafeDeleteDemo values(1000);
Query OK, 1 row affected (0.10 sec)

mysql> insert into SafeDeleteDemo values(150);
Query OK, 1 row affected (0.11 sec)
Display all records from the table before deleting records. The query is as follows −
mysql> select *from SafeDeleteDemo;
The following is the output −
+-------+
| Price |
+-------+
|   100 |
|   200 |
|   300 |
|   500 |
|  1000 |
|   150 |
+-------+
6 rows in set (0.00 sec)
Now delete under safe mode with the help of SET command. The query is as follows −
mysql> SET SQL_SAFE_UPDATES = 0;
Query OK, 0 rows affected (0.00 sec)
Begin with deleting some records the table now. We are in safe mode −
mysql> delete from SafeDeleteDemo where Price >=500;
Query OK, 2 rows affected (0.14 sec)
Now you can check how many records are present in the table after deleting records. The query is as follows −
mysql> select *from SafeDeleteDemo;
The following is the output displaying that we have successfully deleted records >= 500 −
+-------+
| Price |
+-------+
|   100 |
|   200 |
|   300 |
|   150 |
+-------+
4 rows in set (0.00 sec)
Now you can remove delete under safe mode with the help of the same SET command. The query is as follows −
mysql> SET SQL_SAFE_UPDATES = 1;
Query OK, 0 rows affected (0.00 sec)
Python | Reraise the Last Exception and Issue Warning

12 Jun, 2019
Problem – Reraising the exception, that has been caught in the except block.
def example():    try:        int('N/A')    except ValueError:        print("Didn't work")        raise          example()
Output :
Didn't work
Traceback (most recent call last):
    File "", line 1, in 
    File "", line 3, in example
ValueError: invalid literal for int() with base 10: 'N/A'

This problem typically arises when there is no need to take any action in response to an exception (e.g., logging, cleanup, etc.). A very common use might be in catch-all exception handlers.
Code #2 : Catching all exception handlers.
try: ...except Exception as e:    # Process exception information in some way    ...    # Propagate the exception    raise
 Problem 2 – To have a program issue warning messages (e.g., about deprecated features or usage problems).
Code #3: Using the warnings.warn() function
import warningsdef func(x, y, logfile = None, debug = False):    if logfile is not None:        warnings.warn('logfile argument deprecated',                                DeprecationWarning)
The arguments to warn() are a warning message along with a warning class, which is typically one of the following:UserWarning, DeprecationWarning, SyntaxWarning, RuntimeWarning, ResourceWarning, or FutureWarning.The handling of warnings depends on how the interpreter is executed and other configuration.
Output when running Python with the -W all option.
bash % python3 -W all example.py
example.py:5: DeprecationWarning: logfile argument is deprecated
  warnings.warn('logfile argument is deprecated', DeprecationWarning)

Normally, warnings just produce output messages on standard error. To turn warnings into exceptions, use the -W error option.
bash % python3 -W error example.py
Traceback (most recent call last):
    File "example.py", line 10, in 
        func(2, 3, logfile ='log.txt')
    File "example.py", line 5, in func
        warnings.warn('logfile argument is deprecated', DeprecationWarning)
DeprecationWarning: logfile argument is deprecated
bash %

Python-exceptions
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
SQL | CREATE

21 Mar, 2018
There are two CREATE statements available in SQL:
CREATE DATABASECREATE TABLE
CREATE DATABASE
CREATE TABLE
CREATE DATABASE
A Database is defined as a structured set of data. So, in SQL the very first step to store the data in a well structured manner is to create a database. The CREATE DATABASE statement is used to create a new database in SQL.
Syntax:
CREATE DATABASE database_name;

database_name: name of the database.

Example Query:This query will create a new database in SQL and name the database as my_database.
CREATE DATABASE my_database;

CREATE TABLE
We have learned above about creating databases. Now to store the data we need a table to do that. The CREATE TABLE statement is used to create a table in SQL. We know that a table comprises of rows and columns. So while creating tables we have to provide all the information to SQL about the names of the columns, type of data to be stored in columns, size of the data etc. Let us now dive into details on how to use CREATE TABLE statement to create tables in SQL.
Syntax:
CREATE TABLE table_name
(
column1 data_type(size),
column2 data_type(size),
column3 data_type(size),
....
);

table_name:  name of the table.
column1 name of the first column.
data_type: Type of data we want to store in the particular column. 
            For example,int for integer data.
size: Size of the data we can store in a particular column. For example if for
a column we specify the data_type as int and size as 10 then this column can store an integer
number of maximum 10 digits. 

Example Query:This query will create a table named Students with three columns, ROLL_NO, NAME and SUBJECT.
CREATE TABLE Students
(
ROLL_NO int(3),
NAME varchar(20),
SUBJECT varchar(20),
);

This query will create a table named Students. The ROLL_NO field is of type int and can store an integer number of size 3. The next two columns NAME and SUBJECT are of type varchar and can store characters and the size 20 specifies that these two fields can hold maximum of 20 characters.
This article is contributed by Harsh Agarwal. 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.
SQL-Clauses-Operators
Articles
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Time Complexity and Space Complexity
SQL Interview Questions
Understanding "extern" keyword in C
SQL | Views
Java Tutorial
ACID Properties in DBMS
SQL query to find second highest salary?
Normal Forms in DBMS
CTE in SQL
Difference between Clustered and Non-clustered index
Python – Characters occurring in multiple Strings

22 Apr, 2020
Sometimes, while working with Python strings, we can have problem in which we need to extract the characters which have occurrences in more than one string in string list. This kind of problem usually occurs in web development and Data Science domains. Lets discuss certain ways in which this task can be performed.
Method #1 : Using Counter() + set()This is one of the ways in which this task can be performed. In this, we check for all the strings and compute the character frequency in each string and return the character which have more than one string occurrence.
# Python3 code to demonstrate working of # Characters occurring in multiple Strings# Using Counter() + set()from itertools import chainfrom collections import Counter      # initializing listtest_list = ['gfg', 'is', 'best', 'for', 'geeks', 'and', 'cs']  # printing original listprint("The original list is : " + str(test_list))  # Characters occurring in multiple Strings# Using Counter() + set()temp = (set(sub) for sub in test_list)cntr = Counter(chain.from_iterable(temp))res =  [chr for chr, count in cntr.items() if count >= 2]  # printing result print("Characters with Multiple String occurrence : " + str(res)) 
The original list is : [‘gfg’, ‘is’, ‘best’, ‘for’, ‘geeks’, ‘and’, ‘cs’]Characters with Multiple String occurrence : [‘g’, ‘e’, ‘f’, ‘s’]
 
Method #2 : Using list comprehension + Counter() + set()This is one of the way in which this task can be performed. In this, we perform similar task as above, the difference is that we perform in compact and one-liner way using list comprehension.
# Python3 code to demonstrate working of # Characters occurring in multiple Strings# Using list comprehension + Counter() + set()from itertools import chainfrom collections import Counter      # initializing listtest_list = ['gfg', 'is', 'best', 'for', 'geeks', 'and', 'cs']  # printing original listprint("The original list is : " + str(test_list))  # Characters occurring in multiple Strings# Using list comprehension + Counter() + set()res = [key for key, val in Counter([ele for sub in test_list                              for ele in set(sub)]).items()                             if val > 1]  # printing result print("Characters with Multiple String occurrence : " + str(res)) 
The original list is : [‘gfg’, ‘is’, ‘best’, ‘for’, ‘geeks’, ‘and’, ‘cs’]Characters with Multiple String occurrence : [‘g’, ‘e’, ‘f’, ‘s’]
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.str.wrap()

24 Sep, 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 str.wrap() is an important method when dealing with long text data (Paragraphs or messages). This is used to distribute long text data into new lines or handle tab spaces when it exceeds the passed width. Since this is a string method, .str has to be prefixed every time before calling this method.
Syntax: Series.str.wrap(width, **kwargs)
Parameters:width: Integer value, defines maximum line width
**kwargs[Optional parameters]expand_tabs: Boolean value, expands tab characters to spaces if Truereplace_whitespace: Boolean value, if true, each white space character is replaced by single white space.drop_whitespace: Boolean value, If true, removes whitespace if any at the beginning of new linesbreak_long_words: Boolean value, if True, breaks word that are longer than the passed width.break_on_hyphens: Boolean value, if true, breaks string on hyphens where string length is less than width.
Return type: Series with splitted lines/added characters(‘\n’)
To download the data set used in code, 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 :In this example, the Team column is wrapped with a line width of 5 characters. Hence \n will be put after every 5 character. A random element from new team column and old team column is printed to see the working. Before applying any operations, null elements are removed using .dropna() method.
# importing pandas module import pandas as pd  # reading csv file from url data = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   # dropping null value columns to avoid errorsdata.dropna(inplace = True)  # displaydata["New Team"]= data["Team"].str.wrap(5)  # data frame displaydata  # printing same index separatelyprint(data["Team"][120])print("------------")print(data["New Team"][120])
Output:As shown in the output images, the New column has ‘\n’ after every 5 characters. After printing same index of old and New team columns, it can be seen that without adding new line character in print statement, python automatically read ‘\n’ in the string and put it in new line.
Data frame with New Team column-
Output:
Los Angeles Lakers
------------
Los A
ngele
s Lak
ers

Python pandas-series
Python pandas-series-methods
Python-pandas
Python-pandas-series-str
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
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 to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Inverse Gamma Distribution in Python

02 Aug, 2019
Inverse Gamma distribution is a continuous probability distribution with two parameters on the positive real line. It is the reciprocate distribution of a variable distributed according to the gamma distribution. It is very useful in Bayesian statistics as the marginal distribution for the unknown variance of a normal distribution. It is used for considering the alternate parameter for the normal distribution in terms of the precision which is actually the reciprocal of the variance.
It is an inverted gamma continuous random variable. It is an instance of the rv_continuous class. It inherits from the collection of generic methods and combines them with the complete specification of distribution.
Code #1 : Creating inverted gamma continuous random variable
from scipy.stats import invgamma      numargs = invgamma.numargs[a] = [0.3] * numargsrv = invgamma (a)    print ("RV : \n", rv) 
Output :
RV :scipy.stats._distn_infrastructure.rv_frozen object at 0x00000230B0B28748
 Code #2 : Inverse Gamma continuous variates and probability distribution
import numpy as npquantile = np.arange (0.01, 1, 0.1)     # Random VariatesR = invgamma.rvs(a, scale = 2,  size = 10)print ("Random Variates : \n", R)    # PDFR = invgamma .pdf(a, quantile, loc = 0, scale = 1)print ("\nProbability Distribution : \n", R)
Output :
Random Variates : 
 [4.18816252e+00 2.02807957e+03 8.37914946e+01 1.94368997e+00
 3.78345091e+00 1.00496176e+06 3.42396458e+03 3.45520522e+00
 2.81037118e+00 1.72359706e+03]

Probability Distribution : 
 [0.0012104  0.0157619  0.03512042 0.05975504 0.09007126 0.12639944
 0.16898506 0.21798098 0.27344182 0.33532072]
 Code #3 : Graphical Representation.
import numpy as npimport matplotlib.pyplot as plt    distribution = np.linspace(0, np.minimum(rv.dist.b, 3))print("Distribution : \n", distribution)    plot = plt.plot(distribution, rv.pdf(distribution))
Output :
Distribution : 
 [0.         0.06122449 0.12244898 0.18367347 0.24489796 0.30612245
 0.36734694 0.42857143 0.48979592 0.55102041 0.6122449  0.67346939
 0.73469388 0.79591837 0.85714286 0.91836735 0.97959184 1.04081633
 1.10204082 1.16326531 1.2244898  1.28571429 1.34693878 1.40816327
 1.46938776 1.53061224 1.59183673 1.65306122 1.71428571 1.7755102
 1.83673469 1.89795918 1.95918367 2.02040816 2.08163265 2.14285714
 2.20408163 2.26530612 2.32653061 2.3877551  2.44897959 2.51020408
 2.57142857 2.63265306 2.69387755 2.75510204 2.81632653 2.87755102
 2.93877551 3.        ]
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as pltimport numpy as np    x = np.linspace(0, 5, 100)    # Varying positional argumentsy1 = invgamma .pdf(x, 1, 3)y2 = invgamma .pdf(x, 1, 4)plt.plot(x, y1, "*", x, y2, "r--")
Output :
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python MongoDB - Create Collection

A collection in MongoDB holds a set of documents, it is analogous to a table in relational databases.
You can create a collection using the createCollection() method. This method accepts a String value representing the name of the collection to be created and an options (optional) parameter.
Using this you can specify the following −
The size of the collection.
The max number of documents allowed in the capped collection.
Whether the collection we create should be capped collection (fixed size collection).
Whether the collection we create should be auto-indexed.
Following is the syntax to create a collection in MongoDB.
db.createCollection("CollectionName")

Following method creates a collection named ExampleCollection.
> use mydb
switched to db mydb
> db.createCollection("ExampleCollection")
{ "ok" : 1 }
>

Similarly, following is a query that creates a collection using the options of the createCollection() method.
>db.createCollection("mycol", { capped : true, autoIndexId : true, size :
6142800, max : 10000 } )
{ "ok" : 1 }
>

Following python example connects to a database in MongoDB (mydb) and, creates a collection in it.
from pymongo import MongoClient

#Creating a pymongo client
client = MongoClient('localhost', 27017)

#Getting the database instance
db = client['mydb']

#Creating a collection
collection = db['example']
print("Collection created........")
Collection created........


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
C# program to find node in Linked List

Firstly, create a new linked list −
LinkedList<string> myList = new LinkedList<string>();
Now add some elements in the linked list −
// Add 6 elements in the linked list
myList.AddLast("P");
myList.AddLast("Q");
myList.AddLast("R");
myList.AddLast("S");
myList.AddLast("T");
myList.AddLast("U");
Let’s now find a node and add a new node after that −
LinkedListNode<string> node = myList.Find("R");
myList.AddAfter(node, "ADDED");
You can try to run the following code to find a node in the linked list.
Live Demo
using System;
using System.Collections.Generic;
class Program {
   static void Main() {
      LinkedList<string> myList = new LinkedList<string>();
      // Add 6 elements in the linked list
      myList.AddLast("P");
      myList.AddLast("Q");
      myList.AddLast("R");
      myList.AddLast("S");
      myList.AddLast("T");
      myList.AddLast("U");
      LinkedListNode<string> node = myList.Find("R");
      myList.AddAfter(node, "ADDED");
      foreach (var i in myList) {
         Console.WriteLine(i);
      }
   }
}
P
Q
R
ADDED
S
T
U
Fetch unique records from table in SAP ABAP

As you said you are working in ABAP and SQL, so I would expect that you would be using OpenSQL for your SQL activities.
You can get the unique records just by using a DISTINCT operator.
SELECT DISTINCT Name from <Table name> where <clause>
Kotlin Comments

Comments can be used to explain Kotlin code, and to make it more readable. It can also be used to 
prevent execution when testing alternative code.
Single-line comments starts with two forward slashes (//).
Any text between // and the end of the line 
is ignored by Kotlin (will not be executed).
This example uses a single-line comment before a line of code:
// This is a comment
println("Hello World") 
This example uses a single-line comment at the end of a line of code:
println("Hello World")  // This is a comment
Multi-line comments start with /* and ends with */.
Any text between /* and */ will be ignored by Kotlin.
This example uses a multi-line comment (a comment block) to explain the code:
/* The code below will print the words Hello World
to the screen, and it is amazing */
println("Hello World")  
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Java Program to format time with DateFormat.MEDIUM

Use the getTimeInstance() method in Java to get the time format for the locale you have set. DateFormat.MEDIUM is a constant for medium style pattern.
Firstly, we will create a Date object −
Date dt = new Date();
DateFormat dateFormat;
Let us format time for a different locale with DateFormat.MEDIUM
dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.CANADA);
System.out.println("Locale CANADA = " + dateFormat.format(dt));
dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.ITALY);
System.out.println("Locale ITALY = " + dateFormat.format(dt));
The following is an example
 Live Demo
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class Demo {
   public static void main(String args[]) {
      Date dt = new Date();
      DateFormat dateFormat;
      // Displaying time with MEDIUM constant
      dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.FRENCH);
      System.out.println("Locale FRENCH = " + dateFormat.format(dt));
      dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.GERMANY);
      System.out.println("Locale GERMANY = " + dateFormat.format(dt));
      dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.CHINESE);
      System.out.println("Locale CHINESE = " + dateFormat.format(dt));
      dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.CANADA);
      System.out.println("Locale CANADA = " + dateFormat.format(dt));
      dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.ITALY);
      System.out.println("Locale ITALY = " + dateFormat.format(dt));
      dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.TAIWAN);
      System.out.println("Locale TAIWAN = " + dateFormat.format(dt));
   }
}
Locale FRENCH = 09:47:50
Locale GERMANY = 09:47:50
Locale CHINESE = 9:47:50
Locale CANADA = 9:47:50 AM
Locale ITALY = 9.47.50
Locale TAIWAN = 上午 09:47:50
Easiest Guide to Getting Stock Data With Python | by Aidan Wilson | Towards Data Science

I recently finished up an introductory course for data science at my university and for my final project, I decided I wanted to work with stock market data. I wanted to place my focus on the algorithmic trading and needed a quick and easy way to gather stock data that was easily useable.
I came across a library called yfinance and it made my project a lot easier!
I would highly recommend reading through the documentation. Its a quick read that will aid you with any projects involving stock data.
Before we begin, we will need to install the yfinance library. To do this, simply copy the following into your command prompt:
$ pip install yfinance
Now we’re ready to start analyzing our stock market data. For my project, I chose the SPDR S&P 500 ETF Trust, which has the ticker symbol SPY. You can use whichever ticker symbol you want, but I will be using SPY throughout this article.
Fortunately, yfinance makes it extremely easy to pull our data and quickly start analyzing it. We can start by importing yfinance and downloading the historical data of whichever ticker symbol we choose using the .download() function. We can then get a quick look at our data by calling the .head() function to return the first 5 rows of our data.
import yfinance as yfSPY = yf.download('SPY')SPY.head()
Our stock data is nicely formatted in a Pandas DataFrame. This makes it easy, for example, if you were interested in viewing just the closing prices in the dataset.
SPY['Close']
It is also possible to only download data from a certain range of dates. This will require us to use yfinance’s Ticker module, which allows us to do a bit more with yfinance. Once this is done, we can use the .history() function to all of the stock data, or data within a time frame. Let's say we wanted data from the beginning of January 2020 to the beginning of February 2020.
SPY = yf.Ticker('SPY')SPY_History = SPY.history(start="2020-01-01", end="2020-02-01")SPY_History.head()
Now that we have used the Ticker module, we can call.info to view a much more detailed summary of our data. This will return a dictionary containing 100 keys.
SPY.info
That's a lot of data! We can view individual keys in our dictionary as well. For example, if we wanted to see the current 50 Day Average, we could write:
SPY.info['fiftyDayAverage']
Viewing multiple ticker symbols is just as easy. We can use the .download() function again and separate each ticker symbol with a space. We can then view the last 5 rows in our data to check how it is formatted.
data = yf.download('SPY AAPL')data.tail()
For a quick visualization of our data, we can use matplotlib and write a one-liner to compare both SPY and AAPL.
import matplotlib.pyplot as pltdata['Close'].plot(figsize=(10, 5))
For anyone needing to gather stock data quickly and painlessly, yfinance is a great choice and is by far one of the easiest ways to pull stock market data using Python!
SQL - INDEX Constraint

The INDEX is used to create and retrieve data from the database very quickly. An Index can be created by using a single or group of columns in a table. When the index is created, it is assigned a ROWID for each row before it sorts out the data.
Proper indexes are good for performance in large databases, but you need to be careful while creating an index. A Selection of fields depends on what you are using in your SQL queries.
For example, the following SQL syntax creates a new table called CUSTOMERS and adds five columns in it.
CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
   NAME VARCHAR (20)     NOT NULL,
   AGE  INT              NOT NULL,
   ADDRESS  CHAR (25) ,
   SALARY   DECIMAL (18, 2),       
   PRIMARY KEY (ID)
);
Now, you can create an index on a single or multiple columns using the syntax given below.
CREATE INDEX index_name
   ON table_name ( column1, column2.....);

To create an INDEX on the AGE column, to optimize the search on customers for a specific age, you can use the follow SQL syntax which is given below −
CREATE INDEX idx_age
   ON CUSTOMERS ( AGE );

To drop an INDEX constraint, use the following SQL syntax.
ALTER TABLE CUSTOMERS
   DROP INDEX idx_age;


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
How to remove duplicate elements from JavaScript Array ? - GeeksforGeeks

20 Oct, 2021
There are various methods to remove duplicates in the array. We will discuss the most common four ways.
Use the filter() method: The filter() method creates a new array of elements that pass the condition we provide. It will include only those elements for which true is returned. We can remove duplicate values from the array by simply adjusting our condition.
Javascript
<script>    var arr = ["apple", "mango", "apple",             "orange", "mango", "mango"];      function removeDuplicates(arr) {        return arr.filter((item,             index) => arr.indexOf(item) === index);    }      console.log(removeDuplicates(arr));</script>
Output:
["apple", "mango", "orange"]
Using a Set() Method: This method sets a new object type with ES6 (ES2015) that allows you to create collections of unique values.
Javascript
<script>    var arr = ["apple", "mango", "apple",            "orange", "mango", "mango"];      function removeDuplicates(arr) {        return [...new Set(arr)];    }      console.log(removeDuplicates(arr));</script>
Output:
["apple", "mango", "orange"]
Using the forEach() Method: By using forEach() method, we can iterate over the elements in the array, and we will push into the new array if it doesn’t exist in the array.
Javascript
<script>    var arr = ["apple", "mango",         "apple", "orange", "mango", "mango"];      function removeDuplicates(arr) {        var unique = [];        arr.forEach(element => {            if (!unique.includes(element)) {                unique.push(element);            }        });        return unique;    }      console.log(removeDuplicates(arr));</script>
Output:
["apple", "mango", "orange"]
Using the reduce() Method: The reduce() method is used to reduce the elements of the array and combine them into a final array based on some reducer function that you pass.
Javascript
<script>    var arr = ["apple", "mango",         "apple", "orange", "mango", "mango"];      function removeDuplicates(arr) {        var unique = arr.reduce(function (acc, curr) {            if (!acc.includes(curr))                acc.push(curr);            return acc;        }, []);        return unique;    }      console.log(removeDuplicates(arr));</script>
Output:
["apple", "mango", "orange"]
javascript-array
JavaScript-Questions
Picked
TrueGeek-2021
JavaScript
TrueGeek
Web Technologies
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
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
How to redirect to another page in ReactJS ?
Types of Internet Protocols
Basics of API Testing Using Postman
SQL Statement to Remove Part of a String
How to Convert Char to String in Java?
How to use bootstrap datepicker - Learn Tutorials Point

You can add datepicker to your website design,  datepicker  add for “datepicker” function in bootstrap.
<link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css” rel=”stylesheet” type=”text/css” /><link href=”https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.css” rel=”stylesheet” type=”text/css” />
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js”></script><script src=”https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js”></script>
HTML Code

<label>Select Date: </label>
<div class="input-group date">
    <input class="form-control"  id="datepicker" type="text" />
    <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>

javascript

<script>
 $(function () {
   $("#datepicker").datepicker({ 
   autoclose: true, 
   todayHighlight: true
   }).datepicker('update', new Date());
 });
</script>

How to add active class in menu using jquery


How to add/remove textbox dynamically with jQuery


Simple Form validation jQuery snippet


How to create admin login page using PHP?


JavaScript Custom Countdown Timer For Advanced Custom Fields plugin in WordPress

Ajax

Bootstrap

CSS

HTML

Javascript

jQuery

PHP

WordPress





















Your email address will not be published. Required fields are marked *
Comment 
Name * 
Email * 
Website 
 Save my name, email, and website in this browser for the next time I comment.
Create table SQL query in SAP HANA

In below SQL query, you can see a create table command in SQL editor to create a new table with name-“Demo_HANA” in schema name AA_HANA11 with column names- ID and NAME and corresponding data types. In the below example, we have defined ID as “Primary Key” which means it is unique and not null.
Create Table Demo_HANA (
   ID INTEGER,
   NAME VARCHAR(10),
   PRIMARY KEY (ID)
);
CSS - background-position

Sets the initial position of the element's background image, if specified; values normally are paired to provide x, y positions; default position is 0% 0%.
percent
none
length
top
center
bottom
left
right
block-level and replaced elements
object.style.backgroundPosition = "10 30";

Following is the example which demonstrates how to set the background image position 100 pixels away from the left side.
<table style = "background-image:url(/images/pattern1.gif); background-position:100px;">
   <tr>
      <td>
         Background image positioned 100 pixels away from the left.
      </td>
   </tr>
</table>
Following is the example which demonstrates how to set the background image position 100 pixels away from the left side and 200 pixels down from the top.
<html>
   <head>
   </head>

   <body>
      <p style = "background-image:url(/css/images/logo.png);  
         background-position:100px 200px;">
         The background image positioned 100 pixels away from the 
         left and 200  pixels from the top.up
      </p>
   </body>
</html>
It will produce the following result −


      The background image positioned 100 pixels away from the left and 200  pixels from the top.
 

    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Adding new column after a specific column and defining a default in MySQL?

You need to follow some steps to add a new column after a specific column and defining default value. In order to achieve this, you need to use ALTER command. Let us first create a table −
mysql> create table DemoTable
   (
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentFirstName varchar(20),
   StudentAge int,
   StudentCountryName varchar(100)
   );
Query OK, 0 rows affected (0.21 sec)
Let us check the description of table −
mysql> desc DemoTable;
This will produce the following output −
+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| StudentId          | int(11)      | NO   | PRI | NULL    | auto_increment |
| StudentFirstName   | varchar(20)  | YES  |     | NULL    |                |
| StudentAge         | int(11)      | YES  |     | NULL    |                |
| StudentCountryName | varchar(100) | YES  |     | NULL    |                |
+--------------------+--------------+------+-----+---------+----------------+
4 rows in set (0.15 sec)
Following is the query to add a new column after a specific column and defining a default. Let us add a new column “StudentLastName” after column name “StudentFirstName”. The default value of StudentLastName column is “Doe”.
mysql> alter table DemoTable add StudentLastName varchar(20) NOT NULL after StudentFirstName;
Query OK, 0 rows affected (0.91 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table DemoTable alter StudentLastName set default 'Doe';
Query OK, 0 rows affected (0.32 sec)
Records: 0 Duplicates: 0 Warnings: 0
Let us check the description of table once again.
mysql> desc DemoTable;
This will produce the following output −
+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| StudentId          | int(11)      | NO   | PRI | NULL    | auto_increment |
| StudentFirstName   | varchar(20)  | YES  |     | NULL    |                |
| StudentLastName    | varchar(20)  | NO   |     | Doe     |                |
| StudentAge         | int(11)      | YES  |     | NULL    |                |
| StudentCountryName | varchar(100) | YES  |     | NULL    |                |
+--------------------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)
Python | Launch a Web Browser using webbrowser module - GeeksforGeeks

31 Oct, 2021
In Python, webbrowser module is a convenient web browser controller. It provides a high-level interface that allows displaying Web-based documents to users. 
webbrowser can also be used as a CLI tool. It accepts a URL as the argument with the following optional parameters: -n opens the URL in a new browser window, if possible, and -t opens the URL in a new browser tab. 
Python
python -m webbrowser -t "https://www.google.com"
NOTE: webbrowser is part of the python standard library. Therefore, there is no need to install a separate package to use it.
The webbrowser module can be used to launch a browser in a platform-independent manner as shown below:Code #1 : 
Python3
import webbrowserwebbrowser.open('http://www.python.org')
Output : 
True
This opens the requested page using the default browser. To have a bit more control over how the page gets opened, use one of the following functions given below in the code –Code #2 : Open the page in a new browser window. 
Python3
webbrowser.open_new('http://www.python.org')
Output : 
True
Code #3 : Open the page in a new browser tab. 
Python3
webbrowser.open_new_tab('http://www.python.org')
Output : 
True
These will try to open the page in a new browser window or tab, if possible and supported by the browser. To open a page in a specific browser, use the webbrowser.get() function to specify a particular browser.Code #4 : 
Python3
c = webbrowser.get('firefox')c.open('http://www.python.org') c.open_new_tab('http://docs.python.org')
Output : 
True
True
Being able to easily launch a browser can be a useful operation in many scripts. For example, maybe a script performs some kind of deployment to a server and one would like to have it quickly launch a browser so one can verify that it’s working. Or maybe a program writes data out in the form of HTML pages and just like to fire up a browser to see the result. Either way, the webbrowser module is a simple solution. 
stutijain578
python-modules
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
sum() function in Python
Python - Values Frequency Index List - GeeksforGeeks

10 Jul, 2020
Sometimes, while working with Python tuples, we can have a problem in which we need to extract the frequency of each value in tuple. This has been solved earlier. We can have a modification in which we need to create list in which index represents the key and value of it represents the frequency of that index number. This kind of problem can have applications in competitive programming domain. Let’s discuss certain ways in which we need to solve this problem.
Input : test_list = [(‘Gfg’, 1), (‘is’, 1), (‘best’, 1), (‘for’, 1), (‘geeks’, 1)]Output : [0, 5, 0, 0, 0, 0]
Input : test_list = [(‘Gfg’, 5), (‘is’, 5)]Output : [0, 0, 0, 0, 0, 2]
Method #1 : Using loopThis is brute force approach by which this task can be performed. In this, we perform the task of assigning frequency by iterating and assigning pre-initialized list.
# Python3 code to demonstrate working of # Values Frequency Index List# Using loop  # initializing listtest_list = [('Gfg', 3), ('is', 3), ('best', 1), ('for', 5), ('geeks', 1)]  # printing original listprint("The original list is : " + str(test_list))  # Values Frequency Index List# Using loopres = [0 for _ in range(6)]for ele in test_list:    res[ele[1]] = res[ele[1]] + 1  # printing result print("The Frequency list : " + str(res)) 
The original list is : [('Gfg', 3), ('is', 3), ('best', 1), ('for', 5), ('geeks', 1)]
The Frequency list : [0, 2, 0, 2, 0, 1]

 
Method #2 : Using Counter() + list comprehensionThe combination of above functionalities is used to solve this problem. In this, we perform the task of computing frequencies using Counter() and rendering in list is done by list comprehension.
# Python3 code to demonstrate working of # Values Frequency Index List# Using Counter() + list comprehensionfrom collections import Counter  # initializing listtest_list = [('Gfg', 3), ('is', 3), ('best', 1), ('for', 5), ('geeks', 1)]  # printing original listprint("The original list is : " + str(test_list))  # Values Frequency Index List# Using Counter() + list comprehensioncntr = Counter(ele[1] for ele in test_list)res = [cntr[idx] for idx in range(6)]  # printing result print("The Frequency list : " + str(res)) 
The original list is : [('Gfg', 3), ('is', 3), ('best', 1), ('for', 5), ('geeks', 1)]
The Frequency list : [0, 2, 0, 2, 0, 1]

Python List-of-Tuples
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to Install and Configure Synaptic Package Manager in Ubuntu? - GeeksforGeeks

05 Oct, 2021
Synaptic Package Manager is a GUI based package management tool that uses APT (Advanced Package Tool) to installing, updating or removing packages from the Linux system. Some of the feature given by Synaptic Package Manager are: 
 
Allow installing, updating or removing packages
Upgrading whole system
Searching and filtering the list of packages available with APT
Fixing broken package dependencies
Force the installation of a specific package version
 
 
Step 1: To install Synaptic Package Manager, open terminal on your system and enter a command. 
 
$ sudo apt install synaptic
Enter the password, press “Y” and enter. 
 
Step 2: Once the installation completes, you can open the GUI window by typing. 
 
$ sudo synaptic
 
 
Step 1: Search for the required packages in the search bar placed at the top. 
 
Step 2: When you click on the search icon a window will appear, type the name of the package you need. 
 
Step 3: Mark the packages you need from the search list. 
 
and press Apply button on the top bar. 
 
 
sooda367
how-to-install
How To
Installation Guide
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Locale toLanguageTag() Method in Java with Examples - GeeksforGeeks

01 May, 2019
The toLanguageTag() method of Locale class in Java is used to return a well-formed IETF BCP 47 language tag representing this locale object. Now there can be few complications when a language, country or variant does not satisfy the above-mentioned tag which is handled well by this method:
If the mentioned language does not satisfy the tag, then it will be emitted as Undetermined or “und”.
If the mentioned country does not satisfy the tag, it will be omitted.
If the same occurs with the Variant, then each sub-segment is emitted as a subtag.
Syntax:
public String toLanguageTag()
Parameters: This method does not take any parameters.
Return Value: This method returns IETF BCP 47 language tag representation of this locale.
Below programs illustrate the working of toLanguageTag() method:Program 1:
// Java code to illustrate// toLanguageTag() method  import java.util.*;  public class Locale_Demo {    public static void main(String[] args)    {          // Creating a new locale        Locale first_locale            = new Locale("Germany");          // Displaying first locale        System.out.println("Locale: "                           + first_locale);          // Displaying the LanguageTag        System.out.println("The LanguageTag: "                           + first_locale.toLanguageTag());    }}
Locale: germany
The LanguageTag: germany

Program 2:
// Java code to illustrate// toLanguageTag() method  import java.util.*;  public class Locale_Demo {    public static void main(String[] args)    {          // Creating a new locale        Locale first_locale            = new Locale("en", "USA");          // Displaying first locale        System.out.println("Locale: "                           + first_locale);          // Displaying the LanguageTag        System.out.println("The LanguageTag: "                           + first_locale.toLanguageTag());    }}
Locale: en_USA
The LanguageTag: en

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#toLanguageTag()
Java - util package
Java-Functions
Java-Locale
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java