code-rag-bench/online-tutorials huggingface dataset:
decimal keyword in C# - GeeksforGeeks

22 Jun, 2020
Keywords are the words in a language that are used for some internal process or represent some predefined actions.
decimal is a keyword that is used to declare a variable that can store a floating type value from the range of ±1.0 x 10-28 to ±7.9228 x 1028. It is an alias of System.Decimal and occupies 16 bytes (128 bits) in the memory.
Syntax:
decimal variable_name = value;
We have to use ‘m’ or ‘M’ as a suffix with the literal, to represent a decimal value.
Example:
Input: 7271.6521M

Output: num: 7271.6521
        Size of a decimal variable: 16

Input: -371.83436

Output: Type of num: System.Decimal
        num: -371.83436
        Size of a decimal variable: 16

Example 1:
// C# program for decimal keywordusing System;using System.Text;  class GFG {      static void Main(string[] args)    {        // char variable declaration        decimal num1 = 7271.6521M;          // to print value        Console.WriteLine("num: " + num1);          // to print size of a decimal        Console.WriteLine("Size of a decimal variable: " + sizeof(decimal));    }}
Output:
num: 7271.6521
Size of a decimal variable: 16

Example 2:
// C# program for decimal keywordusing System;using System.Text;  namespace geeks {class GFG {      static void Main(string[] args)    {        // char variable declaration        decimal num1 = -371.83436m;          // to print type of variable        Console.WriteLine("Type of num: " + num1.GetType());          // to print value        Console.WriteLine("num: " + num1);          // to print size of a decimal        Console.WriteLine("Size of a decimal variable: " + sizeof(decimal));          // hit ENTER to exit        Console.ReadLine();    }}}
Output:
Type of num: System.Decimal
num: -371.83436
Size of a decimal variable: 16

CSharp-keyword
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#
multimap swap() function in C++ STL

In this article, we will be discussing the working, syntax, and examples of multimap swap() function in C++ STL.
Multimaps are the associative containers, which are similar to map containers. It also facilitates to store the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.
multimap::swap() function is an inbuilt function in C++ STL, which is defined in <map> header file. swap() is used to swap the content of the two multimap containers. This function swaps the values of two multimap containers irrespective of the size of both the multimap containers.
When this function gets called it takes the parameter which is another multimap container and swaps the contents with the associated container.
multimap_name.swap(multimap& multimap_name2);
The function accepts the following parameter(s) −
map_name2 − This is another multimap container’s object whose data we want to swap with the associated multimap container.
map_name2 − This is another multimap container’s object whose data we want to swap with the associated multimap container.
This function returns nothing.
Input 
std::multimap<char, int> odd, eve;
odd.insert(make_pair(‘a’, 1));
odd.insert(make_pair(‘b’, 3));
odd.insert(make_pair(‘c’, 5));
eve.insert(make_pair(‘d’, 2));
eve.insert(make_pair(‘e’, 4));
eve.insert(make_pair(‘f’, 6));
odd.swap(eve);
Output 
Odd: d: 2 e:4 f:6
Eve: a:1 b:3 c:5
 Live Demo
#include<iostream>
#include<map>
using namespace std;
int main(){
   multimap<int,int > mul_1;
   multimap<int,int> mul_2;
   //declaring iterator to traverse the elements
   multimap<int,int>:: iterator i;
   //inserting elements to multimap1
   mul_1.insert({1,10});
   mul_1.insert({2,20});
   mul_1.insert({3,30});
   mul_1.insert({4,40});
   mul_1.insert({5,50});
   //inserting elements to multimap2
   mul_2.insert({6,60});
   mul_2.insert({7,70});
   mul_2.insert({8,80});
   mul_2.insert({9,90});
   //calling swap to swap the elements
   mul_1.swap(mul_2);
   //elements of multimap1
   cout<<"Elements in multimap1 are: "<<"\n";
   for( i = mul_1.begin(); i!= mul_1.end(); i++){
      cout<<(*i).first<<" "<< (*i).second << "\n";
   }
   //elements of multimap2
      cout<<"\nElements in multimap2 are: ";
   for( i = mul_2.begin(); i!= mul_2.end(); i++){
      cout<<(*i).first<<" "<<(*i).second << "\n";
   }
}
If we run the above code it will generate the following output −
Elements in multimap1 are:
6 60
7 70
8 80
9 90
Elements in multimap2 are: 1 10
2 20
3 30
4 40
5 50
Python | Convert Character Matrix to single String - GeeksforGeeks

30 Dec, 2020
Sometimes, while working with Python strings, we can have an option in which we need to perform the task of converting character matrix to a single string. This can have applications in domains in which we need to work with data. Lets discuss certain ways in which we can perform this task.
Method #1 : Using join() + list comprehensionThe combination of above functionalities can be used to perform this task. In this, we just iterate for all lists and join them using join().
# Python3 code to demonstrate working of # Convert Character Matrix to single String# Using join() + list comprehension  # initializing listtest_list = [['g', 'f', 'g'], ['i', 's'], ['b', 'e', 's', 't']]  # printing original listprint("The original list is : " + str(test_list))  # Convert Character Matrix to single String# Using join() + list comprehensionres = ''.join(ele for sub in test_list for ele in sub)  # printing result print("The String after join : " + res) 
The original list is : [['g', 'f', 'g'], ['i', 's'], ['b', 'e', 's', 't']]
The String after join : gfgisbest

 
Method #2 : Using join() + chain()The combination of above functionalities can be used to perform this task. In this, we perform the task performed by list comprehension by chain().
# Python3 code to demonstrate working of # Convert Character Matrix to single String# Using join() + chain()from itertools import chain  # initializing listtest_list = [['g', 'f', 'g'], ['i', 's'], ['b', 'e', 's', 't']]  # printing original listprint("The original list is : " + str(test_list))  # Convert Character Matrix to single String# Using join() + chain()res = "".join(chain(*test_list))  # printing result print("The String after join : " + res) 
The original list is : [['g', 'f', 'g'], ['i', 's'], ['b', 'e', 's', 't']]
The String after join : gfgisbest

Python list-programs
Python matrix-program
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
How to print without newline in Python?
yppasswd - Unix, Linux Command

Today, this versions are deprecated and should not be used any
longer.


Using the command line switches, you can choose whether to update your
password
-p, your login shell
-l, or your GECOS field
-f, or a combination of them.
yppasswd implies the
-p option, if no other option is given. If you use the
-f or
-l option, you also need to add the
-p flag.
ypchfn implies the
-f option, and
ypchsh -l. 

When invoked without the
user argument, the account information for the invoking user will be updated,
otherwise that of
user will be updated. This option is only available to the super-user. If the
yppasswdd daemon on the server supports it, you can give the root password
of the server instead of the users [old] password.


All tools will first prompt the user for the current NIS password needed
for authentication with the
yppasswdd(8)
daemon. Subsequently, the
program prompts for the updated information:

Login shell [/bin/sh]: _

Name [Joe Doe]:
Location [2nd floor, bldg 34]:
Office Phone [12345]:
Home Phone []:

chfn (1)
chfn (1)
chsh (1)
chsh (1)
finger (1)
finger (1)
passwd (1)
passwd (1)
ypcat (1)
ypcat (1)
yppasswdd (8)
yppasswdd (8)
ypserv (8)
ypserv (8)
ypwhich (1)
ypwhich (1)

Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
How to Delete or Remove a File in Golang? - GeeksforGeeks

02 Apr, 2020
In the Go language, you are allowed to remove the existing file with the help of the Remove() method. This method removes the specified file from the director or it also removes empty directories. If the given path is incorrect, then it will throw an error of type *PathError. It is defined under the os package so, you have to import os package in your program for accessing Remove() function.
Syntax:
func Remove(file_name string) error
Example 1:
// Golang program to illustrate how to // remove files from the default directorypackage main   import (    "log"    "os")   func main() {      // Removing file from the directory    // Using Remove() function     e := os.Remove("GeeksforGeeks.txt")    if e != nil {        log.Fatal(e)    }}
Output:
Before:
After:
Example 2:
// Golang program to illustrate how to remove// files from the specified directorypackage main    import (    "log"    "os")    func main() {       // Removing file    // Using Remove() function    e := os.Remove("/Users/anki/Documents/new_folder/GeeksforGeeks.txt")    if e != nil {        log.Fatal(e)     } }
Output:
Before:
After:
Golang-File-Handling
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
strings.Replace() Function in Golang With Examples
Time Formatting in Golang
fmt.Sprintf() Function in Golang With Examples
How to Split a String in Golang?
Arrays in Go
Slices in Golang
Golang Maps
Interfaces in Golang
Inheritance in GoLang
Different Ways to Find the Type of Variable in Golang
Exception Handling in Dart - GeeksforGeeks

20 Jul, 2020
An exception is an error that takes place inside the program. When an exception occurs inside a program the normal flow of the program is disrupted and it terminates abnormally, displaying the error and exception stack as output. So, an exception must be taken care to prevent the application from termination. 
Built-in Exceptions in Dart:  
Every built-in exception in Drat comes under a pre-defined class named Exception. To prevent the program from exception we make use of try/on/catch blocks in Dart.
try { 
   // program that might throw an exception 
}  
on Exception1 { 
   // code for handling exception 1
}  
catch Exception2 { 
   // code for handling exception 2
}

Example 1: Using a try-on block in the dart. 
Dart
void main() {  String geek = "GeeksForGeeks";  try{    var geek2 = geek ~/ 0;    print(geek2);  }  on FormatException{    print("Error!! \nCan't act as input is not an integer.");  }}
 
Output:  
Error!! 
Can't act as input is not an integer.

Example 2: Using a try-catch block in the dart. 
Dart
void main() {  String geek = "GeeksForGeeks";  try{    var geek2 = geek ~/ 0;    print(geek2);  }  catch(e){    print(e);  }}
 
Output:  
Class 'String' has no instance method '~/'.

NoSuchMethodError: method not found: '~/'
Receiver: "GeeksForGeeks"
Arguments: [0]

Final block: The final block in dart is used to include specific code that must be executed irrespective of error in the code. Although it is optional to include finally block if you include it then it should be after try and catch block are over.
finally {
   ...
}

Example:  
Dart
void main() {  int geek = 10;  try{    var geek2 = geek ~/ 0;    print(geek2);  }  catch(e){    print(e);  }  finally {    print("Code is at end, Geek");  }}
 
Output:  
Unsupported operation: Result of truncating division is Infinity: 10 ~/ 0
Code is at end, Geek

Unlike other languages, in Dart to one can create a custom exception. To do, so we make use of throw new keyword in the dart. 
Example: Creating custom exceptions in the dart. 
Dart
// extending Class Age// with Exception classclass Age implements Exception {  String error() => 'Geek, your age is less than 18 :(';}  void main() {  int geek_age1 = 20;  int geek_age2 = 10;      try{    // Checking Age and    // calling if the    // exception occur    check(geek_age1);    check(geek_age2);  }  catch(e){    // Printing error    print(e.error());  }}  // Checking Agevoid check(int age){  if(age < 18){    throw new Age();  }  else  {    print("You are eligible to visit GeeksForGeeks :)");  }}
 
Output: 
You are eligible to visit GeeksForGeeks :)
Geek, your age is less than 18 :(

Dart-Exception-Handling
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - DropDownButton Widget
Flutter - Custom Bottom Navigation Bar
ListView Class in Flutter
Flutter - BoxShadow Widget
Dart Tutorial
Flutter - Checkbox Widget
How to Append or Concatenate Strings in Dart?
Operators in Dart
Flutter - BorderRadius Widget
Flutter - Flexible Widget
Fill bars in a base R barplot with colors based on frequency.

Suppose we have a vector that contains only frequencies and we want to create a bar
chart in base R using these frequencies with color of bars based on frequencies,
therefore, we can use barplot function and providing the color of the bars with as shown
in the below Examples
The function is as follows −
heat.colors function
To fill the bars in a base R barplot with colours based on frequency, use the command given below −
Frequency_1<-c(2,4,8,3,10,1)
barplot(Frequency_1,col=heat.colors(max(Frequency_1))[Frequency_1])
If you execute the above given snippet, it generates the following Output −
To fill the bars in a base R barplot with colours based on frequency, use the command given below −
Frequency_2<-c(25,31,28,21,15,45)
barplot(Frequency_2,col=heat.colors(max(Frequency_2))[Frequency_2])
If you execute the above given snippet, it generates the following Output −
How to use Fab Component in ReactJS? - GeeksforGeeks

20 Jan, 2021
Fab stands for Floating Action Button is which appears in front of all screen content, typically as a circular shape with an icon in its center. Material UI for React has this component available for us and it is very easy to integrate. It can be used to turn an option on or off. We can use the Fab Component in ReactJS using the following approach:
Creating React Application And Installing Module:
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 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
npm install @material-ui/icons
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react';import Fab from '@material-ui/core/Fab';import EditIcon from '@material-ui/icons/Edit';  const App = () => {    return (    <div style={{      margin: 'auto',      display: 'block',      width: 'fit-content'    }}>      <h3>How to use Fab Component in ReactJS?</h3>      <Fab color="secondary" aria-label="edit">        <EditIcon />      </Fab>    </div>  );}  export default App;
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:
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components
Pytest - Environment Setup

In this chapter, we will learn how to install pytest.
To start the installation, execute the following command −
pip install pytest == 2.9.1

We can install any version of pytest. Here, 2.9.1 is the version we are installing.
To install the latest version of pytest, execute the following command −
pip install pytest

Confirm the installation using the following command to display the help section of pytest.
pytest -h


    21 Lectures 
     4 hours 

 Lucian Musat

    22 Lectures 
     1.5 hours 

 Fanuel Mapuwei

    44 Lectures 
     3.5 hours 

 Rohit Dharaviya
 Print
 Add Notes
 Bookmark this page
How to redirect URL to the different website after few seconds?

Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.
To redirect URL to a different website after few seconds, use the META tag, with the content attribute. The attributes set the seconds.
The following is an example of redirecting current page to another website in 10 seconds. The content attribute sets the seconds.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Meta Tag</title>
      <meta http-equiv = "refresh" content = "10; url = https://www.tutorialspoint.com" />
   </head>
   
   <body>
      <p>Hello HTML5!</p>
   </body>
</html>
C# program to multiply all numbers in the list

Firstly, set the list −
List<int> myList = new List<int> () {
   5,
   10,
   7
};
Now, set the value of a variable to 1 that would help us in multiplying −
int prod = 1;
Loop through and get the product −
foreach(int i in myList) {
   prod = prod*i;
}
The following is the code −
 Live Demo
using System;
using System.Collections.Generic;

public class Program {
   public static void Main() {
      List<int> myList = new List<int>() {
         5,
         10,
         7
      };
      Console.WriteLine("List: ");
      foreach(int i in myList) {
         Console.WriteLine(i);
      }
      int prod = 1;
      foreach(int i in myList) {
         prod = prod*i;
      }
      Console.WriteLine("Product: {0}",prod);
   }
}
List:
5
10
7
Product: 350
How to add a constant column in a PySpark DataFrame? - GeeksforGeeks

23 Aug, 2021
In this article, we are going to see how to add a constant column in a PySpark Dataframe. 
It can be done in these ways:
Using Lit()
Using Sql query.
Creating Dataframe for demonstration:
Python3
# Create a spark sessionfrom pyspark.sql import SparkSessionfrom pyspark.sql.functions import litspark = SparkSession.builder.appName('SparkExamples').getOrCreate()  # Create a spark dataframecolumns = ["Name", "Course_Name",           "Months",           "Course_Fees", "Discount",           "Start_Date", "Payment_Done"]data = [    ("Amit Pathak", "Python", 3,     10000, 1000, "02-07-2021", True),    ("Shikhar Mishra", "Soft skills",     2, 8000, 800, "07-10-2021", False),    ("Shivani Suvarna", "Accounting", 6,     15000, 1500, "20-08-2021", True),    ("Pooja Jain", "Data Science", 12,     60000, 900, "02-12-2021", False),]df = spark.createDataFrame(data).toDF(*columns)  # View the dataframedf.show()
Output:
In these methods, we will use the lit() function, Here we can add the constant column ‘literal_values_1’ with value 1 by Using the select method. The lit() function will insert constant values to all the rows. We will use withColumn() select the dataframe:
Syntax: df.withColumn(“NEW_COL”, lit(VALUE))
Example 1: Adding constant value in columns.
Python3
df.withColumn('Status', lit(0)).show()
Output:
Example 2: Adding constant value based on another column.
Python3
from pyspark.sql.functions import when, lit, col  df.withColumn(  "Great_Discount", when(col("Discount") >=1000,lit(    "Yes")).otherwise(lit("NO"))).show()
Output:
Here we will use sql query inside the Pyspark, We will create a temp view of the table with the help of createTempView() and the life of this temp is up to the life of the sparkSession. registerTempTable() will create the temp table if it is not available or if it is available then replace it.
Then after creating the table select the table by SQL clause which will take all the values as a string.
Python3
df.registerTempTable('table')newDF = spark.sql('select *, 1 as newCol from table')newDF.show()
Output:
Picked
Python-Pyspark
Python
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 Convert Python Dictionary To JSON?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
C# | UInt64 Struct - GeeksforGeeks

01 May, 2019
In C#, UInt64 struct is used to represent 64-bit unsigned integers(also termed as the ulong data type) starting from range 0 to 18,446,744,073,709,551,615. It also provides different types of methods to compare instances of this type, convert the value of an instance to its String representation, convert the String representation of a number to an instance of this type, etc. This struct is defined under System namespace. UInt64 struct inherits the ValueType class which inherits the Object class.
Example:
// C# program to illustrate the // fields of UInt64 structusing System;  class GFG {      // Main Method    static public void Main()    {          // Unsigned 64-bit integer        ulong val = 18446744073709551615;          // Checking the unsigned integer        if (val.Equals(UInt64.MinValue))         {            Console.WriteLine("Equal to MinValue!");        }          else if (val.Equals(UInt64.MaxValue))         {            Console.WriteLine("Equal to MaxValue!");        }          else         {            Console.WriteLine("Not Equal!");        }    }}
Equal to MaxValue!

Example:
// C# program to illustrate how to get the // hash code of the 64-bit Unsigned integerusing System;  class GFG {      // Main Method    static public void Main()    {          // UInt64 variable        ulong myval = 3654121225155;          // Get the hash code        // Using GetHashCode Method        int res = myval.GetHashCode();          Console.WriteLine("The hash code of myval is: {0}", res);    }}
The hash code of myval is: -895944559

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.uint64?view=netframework-4.8
CSharp-UInt64-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#
Python - Count of Words with specific letter - GeeksforGeeks

14 Oct, 2020
Given a string of words, extract count of words with specific letter.
Input : test_str = ‘geeksforgeeks is best for geeks’, letter = “g”Output : 2Explanation : “g” occurs in 2 words.
Input : test_str = ‘geeksforgeeks is best for geeks’, letter = “s”Output : sExplanation : “s” occurs in 4 words.
Method #1 : Using list comprehension + len() + split()
This is one of the ways in which this task can be performed. In this, we perform task of extracting words from string using split() and loop is used to iterate words to check for letter existence of letter and len() is used to fetch the number of words with letter.
Python3
# Python3 code to demonstrate working of # Count of Words with specific letter# Using list comprehension + len() + split()  # initializing stringtest_str = 'geeksforgeeks is best for geeks'  # printing original stringprint("The original string is : " + str(test_str))  # initializing letter letter = "e"  # extracting desired count using len()# list comprehension is used as shorthandres = len([ele for ele in test_str.split() if letter in ele])  # printing result print("Words count : " + str(res)) 
The original string is : geeksforgeeks is best for geeks
Words count : 3

Method #2 : Using filter() + lambda + len() + split()
This is yet another way in which this task can be performed. In this, we perform the task of filtering using filter() + lambda.
Python3
# Python3 code to demonstrate working of # Count of Words with specific letter# Using filter() + lambda + len() + split()  # initializing stringtest_str = 'geeksforgeeks is best for geeks'  # printing original stringprint("The original string is : " + str(test_str))  # initializing letter letter = "e"  # extracting desired count using len()# filter() used to check for letter existenceres = len(list(filter(lambda ele : letter in ele, test_str.split())))  # printing result print("Words count : " + str(res)) 
The original string is : geeksforgeeks is best for geeks
Words count : 3

Python string-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 ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
How to create bar plot with positive and negative values in R?

To create bar plot with positive and negative values, we can make use of ggplot function.
For example, if we have a data frame called df that contains a categorical column say C and a numerical column Num which has some positive and some negative values then the bar plot for this data can be created by using the below command −
ggplot(df,aes(C,Num))+geom_bar(stat="identity")
Following snippet creates a sample data frame −
Category<-c("Egypt","Sudan","Turkey","Indonesia")
Response_Score<-c(10,-2,4,-5)
df<-data.frame(Category,Response_Score)
df
The following dataframe is created −
  Category  Response_Score
1  Egypt      10
2  Sudan      -2
3  Turkey      4
4  Indonesia  -5
To load ggplot2 package and create bar chart for data stored in df, add the following code to the above snippet −
library(ggplot2)
ggplot(df,aes(Category,Response_Score))+geom_bar(stat="identity")
If you execute all the above given snippets as a single program, it generates the following output −
What is the difference between Select and SelectMany in Linq C#?

Select operator produces one result value for every source SelectMany Operator belong to Projection Operators category. It is used to project each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence.
class Demo{
   public string Name { get; set; }
   public List<string> Contents { get; set; }
   public static List<Demo>GetAllContents(){
      List<Demo> listContents = new List<Demo>{
         new Demo{
            Name = "Cap",
            Contents = new List<string> { "Nike", "Adidas" }
         },
         new Demo{
            Name = "Shoes",
            Contents = new List<string> { "Nike", "Puma", "Adidas" }
         },
      };
      return listContents;
   }
}
class Program{
   static void Main(){
      IEnumerable<List<string>> result = Demo.GetAllContents().Select(s => s.Contents);
      foreach (List<string> stringList in result){
         foreach (string str in stringList){
            Console.WriteLine(str);
         }
      }
      Console.WriteLine("---Select Many---")
      IEnumerable<string> resultSelectMany = Demo.GetAllContents().SelectMany(s => s.Contents);
      foreach (string str in resultSelectMany){
         Console.WriteLine(str);
      }
      Console.ReadKey();
   }
}
Nike
Adidas
Nike
Puma
Adidas
---Select Many---
Nike
Adidas
Nike
Puma
Adidas
HTTP headers | User-Agent

11 Oct, 2019
The HTTP headers User-Agent is a request header that allows a characteristic string that allows network protocol peers to identify the Operating System and Browser of the web-server. Your browser sends the user agent to every website you connect to. There is no conventional way of writing a user agent string as different browsers use different formats and many web browsers load a lot of information onto their user agents.When your browser is connected to a website, a User-Agent field is included in the HTTP header. The data of the header field varies from browser to browser. This information is used to serve different websites to different web browsers and different operating systems.
Syntax:
User-Agent: <product> / <product-version> <comment>
or
User-Agent: Mozilla/<version> (<system-information>) <platform> (<platform-details>) 
<extensions>
Directives There are three directives in HTTP headers user-agent.
product: This holds the product identity.
product-version: This holds the product version of the used product.
comment: This holds the sub-product information of the used product
You can also check your User-agent with the help of http://whatsmyuseragent.com/.
Example:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
The following conclusions can be drawn with the help of user-agent header:
The user agent application is Mozilla version 5.0.
The operating system is NT version 10.0 (and is running on a Windows(64-bit) Machine).
The engine responsible for displaying content on this device is AppleWebKit version 537.36 (KHTML, an open-source layout engine, is present too).
The client is Chrome version 77.0.3865.90.
The client is based on Safari version 537.36.
Examples:
Mozilla:Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.3
Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/43.4
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.3
Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/43.4
Chrome:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Safari:Mozilla/5.0 (iPhone; CPU iPhone OS 11_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) 
Version/10.0 Mobile/14E304 Safari/602.1
Mozilla/5.0 (iPhone; CPU iPhone OS 11_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) 
Version/10.0 Mobile/14E304 Safari/602.1
Supported Browsers: The browsers compatible with HTTP headers User-Agent are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Dictionary.Clear Method

01 Feb, 2019
This method is used to remove all key/value pairs from the Dictionary<TKey,TValue>.
Syntax:
public void Clear ();

Below are the programs to illustrate the use of above-discussed method:
Example 1:
// C# code to remove all pairs// from Dictionaryusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Create a new dictionary of        // strings, with string keys.        Dictionary<string, string> myDict =           new Dictionary<string, string>();          // Adding key/value pairs in myDict        myDict.Add("Australia", "Canberra");        myDict.Add("Belgium", "Brussels");        myDict.Add("Netherlands", "Amsterdam");        myDict.Add("China", "Beijing");        myDict.Add("Russia", "Moscow");        myDict.Add("India", "New Delhi");          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs "+                "in myDict are : " + myDict.Count);          // Remove all pairs from the Dictionary        myDict.Clear();          Console.WriteLine("After clear operation");          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs in"+                   " myDict  are : " + myDict.Count);    }}
Total key/value pairs in myDict are : 6
After clear operation
Total key/value pairs in myDict  are : 0

Example 2:
// C# code to remove all pairs// from Dictionaryusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Create a new dictionary of         // strings, with string keys.        Dictionary<int, int> myDict =           new Dictionary<int, int>();          // Adding key/value pairs in myDict        myDict.Add(9, 8);        myDict.Add(3, 4);        myDict.Add(4, 7);        myDict.Add(1, 7);          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs "+                "in myDict are : " + myDict.Count);          // Remove all pairs from the Dictionary        myDict.Clear();          Console.WriteLine("After clear operation");          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs"+             " in myDict  are : " + myDict.Count);    }}
Total key/value pairs in myDict are : 4
After clear operation
Total key/value pairs in myDict  are : 0

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.clear?view=netframework-4.7.2
CSharp Dictionary Class
CSharp-Generic-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.xlabels() in Python

12 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The xlabel() function in pyplot module of matplotlib library is used to set the label for the x-axis..
Syntax: matplotlib.pyplot.xlabel(xlabel, fontdict=None, labelpad=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
xlabel: This parameter is the label text. And contains the string value.
labelpad: This parameter is used for spacing in points from the axes bounding box including ticks and tick labels and its default value is None.
**kwargs: This parameter is Text properties that is used to control the appearance of the labels.
Below examples illustrate the matplotlib.pyplot.xlabel() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib.pyplot.xlabels()# function   import numpy as npimport matplotlib.pyplot as plt  t = np.arange(-180.0, 180.0, 0.1)s = np.radians(t)/2.  plt.plot(t, s, '-', lw = 2)  plt.xlabel('Longitude')plt.ylabel('Latitude')plt.title('xlabels() function')plt.grid(True)  plt.show()
Output:
Example #2:
# Implementation of matplotlib.pyplot.xlabels()# function   import numpy as npimport matplotlib.pyplot as plt  valx1 = np.linspace(0.0, 5.0)x2 = np.linspace(0.0, 2.0)  valy1 = np.cos(2 * np.pi * valx1) * np.exp(-valx1)y2 = np.cos(2 * np.pi * x2)  plt.subplot(2, 1, 1)plt.plot(valx1, valy1, 'o-')plt.title('xlabel() Example')plt.ylabel('Damped oscillation')  plt.subplot(2, 1, 2)plt.plot(x2, y2, '.-')plt.xlabel('time (s)')plt.ylabel('Undamped')  plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | First Non-Empty String in list

15 Mar, 2019
Sometimes while dealing with data science, we need to handle a large amount of data and hence we may require shorthands to perform certain tasks. We handle the Null values at preprocessing stage and hence sometimes require to check for the 1st valid element. Let’s discuss certain ways in which we can find the first Non-Empty String.
Method #1 : Using next() + list comprehensionThe next function returns the iterator and hence its more efficient that conventional list comprehension and the logic part is handled using list comprehension which checks for the last None value.
# Python3 code to demonstrate# First Non-Empty String in list# using next() + list comprehension  # initializing listtest_list = ["", "", "Akshat", "Nikhil"]  # printing original list print("The original list : " + str(test_list))  # using next() + list comprehension# First Non-Empty String in listres = next(sub for sub in test_list if sub)  # printing resultprint("The first non empty string is : " + str(res))
The original list : ['', '', 'Akshat', 'Nikhil']
The first non empty string is : Akshat

 
Method #2 : Using filter()The filter function can be used to find the Non empty strings and the 0th index is returned to get the first string among those. Works only with Python 2.
# Python code to demonstrate# First Non-Empty String in list# using filter()  # initializing listtest_list = ["", "", "Akshat", "Nikhil"]  # printing original list print("The original list : " + str(test_list))  # using filter()# First Non-Empty String in listres = filter(None, test_list)[0]  # printing resultprint("The first non empty string is : " + str(res))
The original list : ['', '', 'Akshat', 'Nikhil']
The first non empty string is : Akshat

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
Overloading of Thread class run() method

04 Oct, 2017
Overloading of run() method is possible. But Thread class start() method can invoke no-argument method. The other overloaded method we have to call explicitly like a normal method call.
// Java Program to illustrate the behavior of// run() method overloadingclass Geeks extends Thread {    public void run()    {        System.out.println("GeeksforGeeks");    }    public void run(int i)    {        System.out.println("Bishal");    }}   class Test {    public static void main(String[] args)    {        Geeks t = new Geeks();        t.start();    }}
Output:
GeeksforGeeks
Runtime stack provided by JVM for the above program:
NOTE : Overloaded run() method will be ignored by the Thread class unless we call it ourselves. The Thread class expect a run() with no-arg and that will execute in a separate call stack after the thread has been started. With run(int i), it will not start any separate call stack even if we call it directly. It will be in the same call stack like any other method (if you call from run() method).
Example:
// Java Program to illustrate the execution of// program using main threadclass Geeks extends Thread {    public void run()    {        System.out.println("GeeksforGeeks");    }    public void run(int i)    {        System.out.println("Bishal");    }}   class Test extends Geeks {    public static void main(String[] args)    {        Geeks t = new Geeks();        t.run(1);    }}
Output:
Bishal

Related Article : Overloading Overriding of Thread class start() method
This article is contributed by Bishal Kumar Dubey. 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.
Java-Multithreading
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Scipy integrate.cumtrapz() method

23 Jan, 2020
With the help of scipy.integrate.cumtrapz() method, we can get the cumulative integrated value of y(x) using composite trapezoidal rule by using scipy.integrate.cumtrapz() method.
Syntax : scipy.integrate.cumtrapz()Return : Return the cumulative integrated value of y(x).
Example #1 :In this example we can see that by using scipy.integrate.cumtrapz() method, we are able to get the cumulative integration of y(x) using trapezoidal rule by using this method.
# import numpy and scipy.integrate.cumtrapzimport numpy as npfrom scipy import integrate  x = np.arange(0, 10)y = np.arange(0, 10)# using scipy.integrate.cumtrapz() methodgfg = integrate.cumtrapz(y, x)  print(gfg)
Output :
[0.5 2. 4.5 8. 12.5 18. 24.5 32. 40.5]
Example #2 :
# import numpy and scipy.integrate.cumtrapzimport numpy as npfrom scipy import integrate  x = np.arange(0, 10)y = np.power(x, 2)# using scipy.integrate.cumtrapz() methodgfg = integrate.cumtrapz(y, x)  print(gfg)
Output :
[0.5 3. 9.5 22. 42.5 73. 115.5 172. 244.5]
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Graph measurements: length, distance, diameter, eccentricity, radius, center

31 May, 2021
Prerequisite – Graph Theory Basics – Set 1, Set 2 A graph is defined as set of points known as ‘Vertices’ and line joining these points is known as ‘Edges’. It is a set consisting of where ‘V’ is vertices and ‘E’ is edge. 
 
Vertices: {A, B, C, D, E, F} Edges: {{A, B}, {A, D}, {A, E}, {B, C}, {C, E}, {C, F}, {D, E}, {E, F}} 
Graph Measurements: There are few graph measurement methods available: 
1. Length – Length of the graph is defined as the number of edges contained in the graph. 
 
 
Length of the graph: 8
AB, BC, CD, DE, EF, FA, AC, CE 
2. The distance between two Vertices – The distance between two vertices in a graph is the number of edges in a shortest or minimal path. It gives the available minimum distance between two edges. There can exist more than one shortest path between two vertices. 
 
 
Shortest Distance between 1 - 5 is 2
1 → 2 → 5 
3. Diameter of graph – The diameter of graph is the maximum distance between the pair of vertices. It can also be defined as the maximal distance between the pair of vertices. Way to solve it is to find all the paths and then find the maximum of all. 
 
 
Diameter: 3
BC → CF → FG  
4. Radius of graph –A radius of the graph exists only if it has the diameter. The minimum among all the maximum distances between a vertex to all other vertices is considered as the radius of the Graph G.It is denoted as r(G). 
 
 
Radius: 2
All available minimum radius: 
BC → CF,
BC → CE,
BC → CD,
BC → CA
5. Centre of graph – It consists of all the vertices whose eccentricity is minimum. Here the eccentricity is equal to the radius. For example, if the school is at the centre of town it will reduce the distance buses has to travel. 
 
 
Centre: A  
6. Eccentricity of graph – It is defined as the maximum distance of one vertex from other vertex.The maximum distance between a vertex to all other vertices is considered as the eccentricity of the vertex. It is denoted by e(V). 
 
 
Eccentricity from:
(A, A) = 0
(A, B) = 1
(A, C) = 2
(A, D) = 1
Maximum value  is 2, So Eccentricity is 2
 
VaibhavRai3
ysachin2314
Discrete Mathematics
Picked
Engineering Mathematics
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inequalities in LaTeX
Difference between Propositional Logic and Predicate Logic
Arrow Symbols in LaTeX
Set Notations in LaTeX
Activation Functions
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
C | Dynamic Memory Allocation | Question 7

28 Jun, 2021
What is the problem with following code?
#include<stdio.h>int main(){    int *p = (int *)malloc(sizeof(int));      p = NULL;      free(p);}
(A) Compiler Error: free can’t be applied on NULL pointer(B) Memory Leak(C) Dangling Pointer(D) The program may crash as free() is called for NULL pointer.Answer: (B)Explanation: free() can be called for NULL pointer, so no problem with free function call.
The problem is memory leak, p is allocated some memory which is not freed, but the pointer is assigned as NULL. The correct sequence should be following:
    free(p);
    p = NULL;

Quiz of this Question
C-Dynamic Memory Allocation
Dynamic Memory Allocation
C Language
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Function Pointer in C
Left Shift and Right Shift Operators in C/C++
Different Methods to Reverse a String in C++
std::string class in C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Storage Classes and Type Qualifiers | Question 1
Output of C programs | Set 64 (Pointers)
C | File Handling | Question 1
HTTP headers | Date

18 Oct, 2019
Description:HTTP headers are used to pass additional information with HTTP response or HTTP request. Date HTTP header contains the date and time at which the message was generated. It is supported by all the browsers.
Syntax:
Date: day-name, day month year hour:minute:second GMT
Directives:
day-name: It is case sensitive directive and specifies the day name when message was generated. The values it can have “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”, or “Sun” as value.
day: It specifies the day of month in 2 digit format. It can have values ranging from ’00’ to ’31’. For ex. 01, 21, 29
month: It specifies the month name and is case sensitive. It can have “Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec” as value.
year: It specifies the year in 4 digit format. For ex 2019, 2018.
hour: It specifies hour in 24 hour, 2 digit format. It can have values ranging from ’00’ to ’23’. For ex. 10, 21
minute: It specifies minute in 2 digit format. It can have values ranging from ’00’ to ’59’. For ex. 05, 21
second: It specifies second in 2 digit format. It can have values ranging from ’00’ to ’59’. For ex. 05, 21
GMT: GMT stands for Greenwich mean time.
Example:
Date: Wed, 16 Oct 2019 07:28:00 GMT 
Supported Browsers: The browsers compatible with HTTP headers date are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
Node.js fs.readFileSync() Method
How to create footer to stay at the bottom of a Web page?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Difference Between PUT and PATCH Request
Python | sympy.Mod() method

02 Aug, 2019
With the help of sympy.Mod() method, we can find the modulus and can give the parameters separately by using sympy.Mod() method.
Syntax : sympy.Mod(var1, var2)Return : Return a value of modulo.
Example #1 :In this example we can see that by using sympy.Mod() method, we are able to find the modulus for a given parameters.
# import sympyfrom sympy import *   x, y = symbols('x y')  # Using sympy.Mod() methodgfg = Mod(x, y).subs({x:7, y:2})  print(gfg)
Output :
1
Example #2 :
# import sympyfrom sympy import *   x, y = symbols('x y')  # Using sympy.Mod() methodgfg = Mod(x**2, y).subs({x:7, y:5})  print(gfg)
Output :
4
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Queue in Python
Defaultdict in Python
Check if element exists in list in Python
Python Classes and Objects
Bar Plot in Matplotlib
reduce() in Python
Python | Get unique values from a list