code-rag-bench/online-tutorials huggingface dataset:
Convert PySpark dataframe to list of tuples

18 Jul, 2021
In this article, we are going to convert the Pyspark dataframe into a list of tuples.
The rows in the dataframe are stored in the list separated by a comma operator. So we are going to create a dataframe by using a nested list
Creating Dataframe for demonstration:
Python3
# importing moduleimport pyspark  # importing sparksession from pyspark.sql modulefrom pyspark.sql import SparkSession  # creating sparksession and giving an app namespark = SparkSession.builder.appName('sparkdf').getOrCreate()  # list  of students  datadata = [["1", "sravan", "vignan", 67, 89],        ["2", "ojaswi", "vvit", 78, 89],        ["3", "rohith", "vvit", 100, 80],        ["4", "sridevi", "vignan", 78, 80],        ["1", "sravan", "vignan", 89, 98],        ["5", "gnanesh", "iit", 94, 98]]  # specify column namescolumns = ['student ID', 'student NAME',           'college', 'subject1', 'subject2']  # creating a dataframe from the lists of datadataframe = spark.createDataFrame(data, columns)  # displaydataframe.show()
Output: 
By converting each row into a tuple and by appending the rows to a list, we can get the data in the list of tuple format.
tuple(): It is used to convert data into tuple format
Syntax: tuple(rows)
Example: Converting dataframe into a list of tuples.
Python3
# define a listl=[]  # collect data from the  dataframefor i in dataframe.collect():   l.append(tuple(i))   # convert to tuple and append to list     # print list of dataprint(l)
Output:
[(‘1’, ‘sravan’, ‘vignan’, 67, 89), (‘2’, ‘ojaswi’, ‘vvit’, 78, 89), 
(‘3’, ‘rohith’, ‘vvit’, 100, 80), (‘4’, ‘sridevi’, ‘vignan’, 78, 80),
 (‘1’, ‘sravan’, ‘vignan’, 89, 98), (‘5’, ‘gnanesh’, ‘iit’, 94, 98)]
Convert rdd to a tuple using map() function, we are using map() and tuple() functions to convert from rdd
Syntax: rdd.map(tuple)
Example: Using RDD
Python3
# convert dataframe to rddrdd = dataframe.rdd  # convert rdd to tupledata = rdd.map(tuple)  # display datadata.collect()
Output:
[('1', 'sravan', 'vignan', 67, 89),
('2', 'ojaswi', 'vvit', 78, 89),
('3', 'rohith', 'vvit', 100, 80),
('4', 'sridevi', 'vignan', 78, 80),
('1', 'sravan', 'vignan', 89, 98),
('5', 'gnanesh', 'iit', 94, 98)]
Picked
Python-Pyspark
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Using a variable as format specifier in C

29 May, 2017
It is known that, printf() function is an inbuilt library function in C programming language in the header file stdio.h. It is used to print a character, string, float, integer etc. onto the output screen. However, while printing the float values, the number of digits following the decimal point can be controlled by the user. One of the ways to do that is by using formats like %.2f etc. But variables can also be used for formatting format specifiers.
Below example shows how this can be done.
// C program to demonstrate use of variable// in format specifier.#include <stdio.h>  int main(){    float b = 6.412355;      // using the format specifier %.*f    // a = 3 will print value of b upto    // 3 decimal places    int a = 3;    printf("%.*f\n", a, b);      // a = 5 will print value of b upto    // 3 decimal places    a = 5;    printf("%.*f\n", a, b);    return 0;}
Output:
6.412
6.41235

This article is contributed by MAZHAR IMAM KHAN. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-input-output
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
std::string class in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Unordered Sets in C++ Standard Template Library
List in C++ Standard Template Library (STL)
std::find in C++
Inline Functions in C++
How to set the div height to auto-adjust to background size?

08 Jun, 2020
Sometimes, while creating a website, it is required to make a div adjust its height automatically according to the background without having the need to set a specific height or min-height. It makes it convenient for the developer while writing the code. 
We’ll create an img element inside our div and will set its src same as that of our background image. It’s visibility will be set as hidden so that only the background image will appear. Set the background-repeat property of the div element to “no-repeat” so as not to repeat the image. 
Example:  Since the image is the background image of the div, therefore, the heading GeeksforGeeks appears over the image.
html
<!DOCTYPE html><html>    <head>        <title>Title of the document</title>        <style>            div {                background-image: url(https://media.geeksforgeeks.org/wp-content/uploads/20200602195146/0.jpeg);                background-repeat: no-repeat;            }            img {                visibility: hidden;            }            h1 {                position: absolute;                left: 35%;                top: 30%;                color: white;            }        </style>    </head>    <body>        <div>            <h1>GeeksforGeeks</h1>            <img src="https://media.geeksforgeeks.org/wp-content/uploads/20200602195146/0.jpeg"                  alt="Image" />        </div>    </body></html>
Output: 
CSS-Properties
Picked
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Form validation using jQuery
Design a web page using HTML and CSS
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
HTTP headers | Content-Type
Python | dtype object length of Numpy array of strings

14 Mar, 2019
In this post, we are going to see the datatype of the numpy object when the underlying data is of string type. In numpy, if the underlying data type of the given object is string then the dtype of object is the length of the longest string in the array. This is so because we cannot create variable length string in numpy since numpy needs to know how much space should be allocated for string.
Problem #1 : Given a numpy array whose underlying data is of string type. Find the dtype.
Solution : We will use numpy.dtype attribute to check the dtype of the given object.
# importing the numpy library as npimport numpy as np  # Create a numpy arrayarr = np.array(['Ela', 'Ed', 'Brook', 'Sia', 'Katherine'])  # Print the arrayprint(arr)
Output :
Now we will check the dtype of the given array object whose underlying data is of string type.
# Print the dtypeprint(arr.dtype)
Output :As we can see in the output, the dtype of the given array object is '<U9' where 9 is the length of the longest string in the given array object.
Let’s verify this by checking the length of the longest string in the given object.
# Use vectorize function of numpylength_checker = np.vectorize(len)  # Find the length of each elementarr_len = length_checker(arr)  # Print the length of each elementprint(arr_len)  # Print the maximum valueprint(arr_len.max())
Output : Problem #2 : Given a numpy array whose underlying data is of string type. Find the dtype.
Solution : We will use numpy.dtype attribute to check the dtype of the given object.
# importing the numpy library as npimport numpy as np  # Create a numpy arrayarr = np.array(['New York', 'Lisbon', 'Beijing', 'Quebec'])  # Print the arrayprint(arr)
Output :
Now we will check the dtype of the given array object whose underlying data is of string type.
# Print the dtypeprint(arr.dtype)
Output :As we can see in the output, the dtype of the given array object is '<U8' where 8 is the length of the longest string in the given array object.
Let’s verify this by checking the length of the longest string in the given object.
# Use vectorize function of numpylength_checker = np.vectorize(len)  # Find the length of each elementarr_len = length_checker(arr)  # Print the length of each elementprint(arr_len)  # Print the maximum valueprint(arr_len.max())
Output :
Python numpy-program
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JSTL - Core <fmt:formatDate> Tag

The <fmt:formatDate> tag  is used to format dates in a variety of ways.
The <fmt:formatDate> tag has the following attributes −
The pattern attribute is used to specify even more precise handling of the date −
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>

<html>
   <head>
      <title>JSTL fmt:dateNumber Tag</title>
   </head>

   <body>
      <h3>Number Format:</h3>
      <c:set var = "now" value = "<% = new java.util.Date()%>" />

      <p>Formatted Date (1): <fmt:formatDate type = "time" 
         value = "${now}" /></p>
      
      <p>Formatted Date (2): <fmt:formatDate type = "date" 
         value = "${now}" /></p>
      
      <p>Formatted Date (3): <fmt:formatDate type = "both" 
         value = "${now}" /></p>
      
      <p>Formatted Date (4): <fmt:formatDate type = "both" 
         dateStyle = "short" timeStyle = "short" value = "${now}" /></p>
      
      <p>Formatted Date (5): <fmt:formatDate type = "both" 
         dateStyle = "medium" timeStyle = "medium" value = "${now}" /></p>
      
      <p>Formatted Date (6): <fmt:formatDate type = "both" 
         dateStyle = "long" timeStyle = "long" value = "${now}" /></p>
      
      <p>Formatted Date (7): <fmt:formatDate pattern = "yyyy-MM-dd" 
         value = "${now}" /></p>

   </body>
</html>
The above code will generate the following result −
Date Format:
Formatted Date (1): 14:27:18
Formatted Date (2): 23-Sep-2010
Formatted Date (3): 23-Sep-2010 14:27:18
Formatted Date (4): 23/09/10 14:27
Formatted Date (5): 23-Sep-2010 14:27:18
Formatted Date (6): 23 September 2010 14:27:18 GST
Formatted Date (7): 2010-09-23

Formatted Date (1): 14:27:18
Formatted Date (2): 23-Sep-2010
Formatted Date (3): 23-Sep-2010 14:27:18
Formatted Date (4): 23/09/10 14:27
Formatted Date (5): 23-Sep-2010 14:27:18
Formatted Date (6): 23 September 2010 14:27:18 GST
Formatted Date (7): 2010-09-23
Convert XML to CSV in Python

24 Jan, 2021
Prerequisites: Pandas
XML stands for Extensible Markup Language. This format is extremely useful for keeping track of small to medium amounts of data. As the data in XML format is not readable by general users, we need to convert it to some user-friendly format like CSV. CSV is easily readable and can be opened using any editor.
Now, let’s take an example to convert XML data to CSV data using python. We will import ElementTree for parsing data of XML format to CSV format. The xml.etree.ElementTree module implements a simple and efficient API for parsing and creating XML data.
Import module
Declare rows and columns for the data to arranged in csv file
Load xml file
Parse xml file
Write each row to csv file one by one
Save csv file
XML data used : 
Link: sample.xml
Program:
Python3
# Importing the required librariesimport xml.etree.ElementTree as Xetimport pandas as pd  cols = ["name", "phone", "email", "date", "country"]rows = []  # Parsing the XML filexmlparse = Xet.parse('sample.xml')root = xmlparse.getroot()for i in root:    name = i.find("name").text    phone = i.find("phone").text    email = i.find("email").text    date = i.find("date").text    country = i.find("country").text      rows.append({"name": name,                 "phone": phone,                 "email": email,                 "date": date,                 "country": country})  df = pd.DataFrame(rows, columns=cols)  # Writing dataframe to csvdf.to_csv('output.csv')
Output:
Picked
python-csv
Python-XML
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to align a logo image to center of navigation bar using HTML and CSS ? - GeeksforGeeks

23 Nov, 2020
Problem statement: You must have seen that while applying margin:auto property to the image tag in the navigation bar, the logo image in the navigation bar does not get centered.
Approach: As the image tag in CSS is an inline element, so the image tag will occupy only that much space which is required by it. So, in order to resolve this problem, we have assigned the display property of the image tag to “block” and then assign proper width and height to it. Assign the margin to “auto”. You will see that the logo image is now centered in the navigation bar.
HTML code: Following demonstrates the code for the above approach.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=        "width=device-width, initial-scale=1.0">              <style>        #navbar {            width: 100vw;            height: 40px;            border: 3px solid white;            border-radius: 15px;            background-color: green;        }          #navbar img {            display: block;            width: 40px;            height: 40px;            margin: auto;          }    </style></head>  <body>    <nav id="navbar">        <img src="5.jpeg" alt="Logo image">    </nav></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
Technical Scripter 2020
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
How to create a label using JavaFX?

You can display a text element/image on the User Interface using the Label
component. It is a not editable text control, mostly used to specify the purpose of
other nodes in the application.
In JavaFX, you can create a label by instantiating the javafx.scene.control.Label class.
Just like a text node you can set the desired font to the text node in JavaFX using the setFont() method and, you can add color to it using the setFill() method.
To create a label −
Instantiate the Label class.
Instantiate the Label class.
Set the required properties to it.
Set the required properties to it.
Add the label to the scene.
Add the label to the scene.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
public class LabelExample extends Application {
   public void start(Stage stage) {
      //Creating a Label
      Label label = new Label("Sample label");
      //Setting font to the label
      Font font = Font.font("Brush Script MT", FontWeight.BOLD, FontPosture.REGULAR, 25);
      label.setFont(font);
      //Filling color to the label
      label.setTextFill(Color.BROWN);
      //Setting the position
      label.setTranslateX(150);
      label.setTranslateY(25);
      Group root = new Group();
      root.getChildren().add(label);
      //Setting the stage
      Scene scene = new Scene(root, 595, 150, Color.BEIGE);
      stage.setTitle("Label Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Set the base time zone offset to GMT in Java

In order to set the base time zone to GMT in Java, we use the setRawOffset(int offsetMillis) method. The java.util.TimeZone.setRawOffset(int offsetMillis) method set the base timezone offset to GMT.
Declaration − The java.util.TimeZone.setRawOffset(int offsetMillis) method is declared as follows −
public abstract void setRawOffset(int offsetMillis)
where offsetMillis is the given base time zone offset to GMT.
Let us set the base timezone offset to GMT in Java −
 Live Demo
import java.util.*;
public class Example {
   public static void main( String args[] ) {
      // creating default object of TimeZone
      TimeZone obj = TimeZone.getDefault();
      System.out.println("Default timezone object: \n" + obj);
      // setting the raw offset
      obj.setRawOffset(25000);
      System.out.println("The value of the offset is :" + obj.getRawOffset());
   }
}
Default timezone object: sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
The value of the offset is :25000
Unit Testing in Python using Unittest

In this article, we will learn about the fundamentals of software testing with the help of the unit test module available in Python 3.x. Or earlier. It allows automation, sharing of the setup and exit code for tests, and independent tests for every framework.
In the unit tests, we use a wide variety of object-oriented concepts. We will be discussing some majorly used concepts here.
Testcase − It is response specific base class in accordance with a given set of inputs. We use base class of unit test i.e. “TestCase” to implement this operation.
Testcase − It is response specific base class in accordance with a given set of inputs. We use base class of unit test i.e. “TestCase” to implement this operation.
Testsuite − It is used to club test cases together and execute them simultaneously.
Testsuite − It is used to club test cases together and execute them simultaneously.
Testrunner − It follows an outcome-based execution of tasks. It is involved in displaying the results after executing the tasks.
Testrunner − It follows an outcome-based execution of tasks. It is involved in displaying the results after executing the tasks.
Test fixture − It serves as a baseline for the test cases in the associated environment.
Test fixture − It serves as a baseline for the test cases in the associated environment.
Now lets a basic example to see how unit testing works.
 Live Demo
import unittest
class TestStringMethods(unittest.TestCase):
   def test_upper(self):
      self.assertEqual('TUTOR'.lower(), 'tutor')
   def test_islower(self):
      self.assertTrue('tutor'.islower())
      self.assertFalse('Tutor'.islower())
if __name__ == '__main__':
   unittest.main()
...
---------------------------------------------------------------

Ran 2 tests in 0.000s
OK
Here we extend the unit test class in the form of single inheritance. Here we used to built-in methods like assertEqual() , assertTrue() & assertFalse()
assertEqual() is used to validate/compare the output with the result
assertTrue() is used to verify that the given condition is True or not.
assertFalse() is used to verify that the given condition is False or not.
The output of the above code can be in three forms −
OK – This indicates that all tests generated have executed successfully
FAIL – This indicates either test case has failed and an AssertionError exception is raised.
ERROR – This indicates that the test raises an exception/error.
We can use the decorator @unittest.skip(<reason>)
 Live Demo
import unittest
class TestString(unittest.TestCase):
   @unittest.skip("check skipped tests")
   def test_upper(self):
      self.assertEqual('TUTOR'.lower(), 'tutor')
   def test_islower(self):
      self.assertTrue('tutor'.islower())
      self.assertFalse('Tutor'.islower())
if __name__ == '__main__':
   unittest.main()
...
---------------------------------------------------------------
-
Ran 2 tests in 0.000s
OK (skipped=2)
In this article, we learned about Unit Testing in Python using the unittest module in Python 3.x. Or earlier.
How can I make a time delay in Python?

In order to introduce delay of definite interval, we can use sleep() function that is available in time module of Standard Python library. The sleep() function takes an integer number corresponding to seconds as an argument.
time.sleep(sec)
In following example, current time is first displayed and then the execution is paused for 10 seconds using sleep() function.
import time
print ("current time : ",time.ctime())
time.sleep(10)
 print ("after 10 sec : ",time.ctime())
Python 3 - String isspace() Method

The isspace() method checks whether the string consists of whitespace.
Following is the syntax for isspace() method −
str.isspace()

NA
This method returns true if there are only whitespace characters in the string and there is at least one character, false otherwise.
The following example shows the usage of isspace() method.
#!/usr/bin/python3

str = "       " 
print (str.isspace())

str = "This is string example....wow!!!"
print (str.isspace())
When we run above program, it produces the following result −
True
False


    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
DateTime.SpecifyKind() Method in C# - GeeksforGeeks

06 Feb, 2019
This method is used to create a new DateTime object which has the same number of ticks as the specified DateTime but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value.
Syntax: public static DateTime SpecifyKind (DateTime value, DateTimeKind kind);
Parameters:value: It is the date and time.kind: It is one of the enumeration values which indicates whether the new object represents local time, UTC, or neither.
Return Value: This method returns a new object that has the same number of ticks as the object represented by the value parameter and the DateTimeKind value specified by the kind parameter.
Below programs illustrate the use of DateTime.SpecifyKind(DateTime, DateTimeKind) Method:
Example 1:
// C# program to demonstrate the// DateTime.SpecifyKind(DateTime,// DateTimeKind) Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(2005, 5,                                6, 14, 34, 42);                                          Console.WriteLine("Kind Before Using Method: "                                          +date.Kind);          // getting DateTime of same DateTime         // instance using SpecifyKind() method        DateTime value = DateTime.SpecifyKind(date,                            DateTimeKind.Local);                                      Console.WriteLine("Kind After Using Method: " +                                            value.Kind);          Console.WriteLine("DateTime is {0}",                                    value);    }}
Kind Before Using Method: Unspecified
Kind After Using Method: Local
DateTime is 05/06/2005 14:34:42

Example 2:
// C# program to demonstrate the// DateTime.SpecifyKind(DateTime,// DateTimeKind) Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(1970, 1,                                1, 4, 0, 15);          // getting DateTime of same DateTime         // instance using SpecifyKind() method        DateTime value = DateTime.SpecifyKind(date,                               DateTimeKind.Local);          Console.WriteLine("DateTime is {0}", value);    }}
DateTime is 01/01/1970 04:00:15

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.specifykind?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
C# | Inheritance
Partial Classes in C#
C# | List Class
Lambda Expressions in C#
Difference between Hashtable and Dictionary in C#
Convert String to Character Array in C#
HTML DOM appendChild() Method

The HTML DOM appendChild() method is used to create and add a text node at the end of the list of child nodes. The appendChild() method can also be used to move an element from current position to a new position. Using appendChild() you can add new values to a list and can even add a new paragraph under another paragraph.
Following is the syntax for appendChild() Method −
node.appendChild( node )
Here, the parameter node is the object that you want to append. It is a compulsory parameter value.
Let us see an example of appendChild() Method −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create a paragraph and append it to the div</p>
<div id="SampleDIV">
A DIV element
</div>
<button onclick="AppendP()">Append</button>
<script>
   var x=1;
   function AppendP() {
      var paragraph = document.createElement("P");
      paragraph.innerHTML = "This is paragraph "+x;
      document.getElementById("SampleDIV").appendChild(paragraph);
      x++;
   }
</script>
</body>
</html>
This will produce the following output −
After clicking append 3 times: −
In the above example −
We have created a div with id “SampleDIV”. The appended node will act as child of this div.
<div id="SampleDIV">
A DIV element
</div>
We have then a button named “Append” which will execute the function AppendP()
<button onclick="AppendP()">Append</button>
The AppendP() function first creates a paragraph (p) element and assigns it to variable paragraph. Then some text is added to paragraph using innerHTML and a variable x is appended to text. This variable is incremented each time we click the ”Append” button. At last we append the newly created paragraph as a child node of the div element −
var x=1;
function AppendP() {
   var paragraph = document.createElement("P");
   paragraph.innerHTML = "This is paragraph "+x;
   document.getElementById("SampleDIV").appendChild(paragraph);
   x++;
}
Get the items which are not common of two Pandas series - GeeksforGeeks

01 Aug, 2020
Pandas does not support specific methods to perform set operations. However, we can use the following formula to get unique items from both the sets :
Algorithm :
Import the Pandas and NumPy modules.Create 2 Pandas Series.Find the union of the series using the union1d() method.Find the intersection of the series using the intersect1d() method.Find the difference between the union and the intersection elements. Use the isin() method to get the boolean list of items present in both ‘union’ and ‘intersect’.Print the result
Import the Pandas and NumPy modules.
Create 2 Pandas Series.
Find the union of the series using the union1d() method.
Find the intersection of the series using the intersect1d() method.
Find the difference between the union and the intersection elements. Use the isin() method to get the boolean list of items present in both ‘union’ and ‘intersect’.
Print the result
# import the modulesimport pandas as pd import numpy as np  # create the series ser1 = pd.Series([1, 2, 3, 4, 5])ser2 = pd.Series([3, 4, 5, 6, 7])  # union of the seriesunion = pd.Series(np.union1d(ser1, ser2))  # intersection of the seriesintersect = pd.Series(np.intersect1d(ser1, ser2))  # uncommon elements in both the series notcommonseries = union[~union.isin(intersect)]  # displaying the resultprint(notcommonseries)
Output :
1, 2, 6, 7
Python pandas-series
Python-pandas
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 drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
C library function - puts()

The C library function int puts(const char *str) writes a string to stdout up to but not including the null character. A newline character is appended to the output.
Following is the declaration for puts() function.
int puts(const char *str)
str − This is the C string to be written.
str − This is the C string to be written.
If successful, non-negative value is returned. On error, the function returns EOF.
The following example shows the usage of puts() function.
#include <stdio.h>
#include <string.h>

int main () {
   char str1[15];
   char str2[15];

   strcpy(str1, "tutorialspoint");
   strcpy(str2, "compileonline");

   puts(str1);
   puts(str2);
   
   return(0);
}
Let us compile and run the above program to produce the following result −
tutorialspoint
compileonline


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
C# program to replace n-th character from a given index in a string

Firstly, set a string.
string str1 = "Port";
Console.WriteLine("Original String: "+str1);
Now convert the string into character array.
char[] ch = str1.ToCharArray();
Set the character you want to replace with the index of the location. To set a character at position 3rd.
ch[2] = 'F';
To remove nth character from a string, try the following C# code. Here, we are replacing the first character.
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(string[] args) {
      string str1 = "Port";
      Console.WriteLine("Original String: "+str1);
      char[] ch = str1.ToCharArray();
      ch[0] = 'F';
      string str2 = new string (ch);
      Console.WriteLine("New String: "+str2);
   }
}
Original String: Port
New String: Fort
Java Online Compiler (Editor / Interpreter)

With our online Java compiler, you can edit Java code, and view the result in your browser.
public class Main {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}

Click on the "Try it Yourself" button to see how it works.
The window to the left is editable - edit the code and click on the "Run" button to view the result in the right window.
The icons are explained in the table below:
If you don't know Java, we suggest that you read our Java Tutorial from scratch.
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.
How to set the unit length of an axis in Matplotlib?

To set the unit length of an axis in Matplotlib, we can use xlim or ylim with scale factor of the axes, i.e., of unit length times.
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Create x and y data points using numpy.
Plot the x and y data points using plot() method.
Plot the x and y data points using plot() method.
Get the x and y axes, limit range.
Get the x and y axes, limit range.
Use xlim and ylim methods to set the unit length scale.
Use xlim and ylim methods to set the unit length scale.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import numpy as np

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

x = np.linspace(1, 10, 100)
y = np.log(x)

plt.plot(x, y)
axis_scale = 2

xmin, xmax = plt.xlim()
ymin, ymax = plt.ylim()

plt.xlim(xmin * axis_scale, xmax * axis_scale)
plt.ylim(ymin * axis_scale, ymax * axis_scale)

plt.show()
C++ Program to Find Minimum Element in an Array using Linear Search

This is a C++ Program to find the minimum element of an array using Linear Search approach. The time complexity of this program is O(n).
Begin
   Assign the data element to an array.
   Assign the value at ‘0’ index to minimum variable.
   Compare minimum with other data element sequentially.
   Swap values if minimum value is more then the value at that particular index of the array.
   print the minimum value.
End
#include<iostream>
using namespace std;
int main() {
   int n, i, minimum, a[10] = {1, 6, 7, 10, 12, 14, 12, 16, 20, 26};
   char ch;
   minimum = a[0];
   cout<<"\nThe data element of array:";
   for(i = 0; i < 10; i++) {
      cout<<" "<<a[i];
      if(minimum > a[i])
         minimum= a[i];
   }
   cout<<"\n\nMinimum of the data elements of array using linear search is: "<<minimum;
   return 0;
}
The data element of array: 1 6 7 10 12 14 12 16 20 26
Minimum of the data elements of array using linear search is: 1
How to group data with Angular filter ?

29 Jul, 2020
The task is to show how to group-data with an Angular-filter.
Steps involved:
1. You can install angular-filter using these four different methods:
Clone & build https://github.com/a8m/angular-filter git repository
Via Bower: by running $ bower install angular-filter from your terminal
Via npm: by running $ npm install angular-filter from your terminal.
Installing via npm 
Via cdnjs: add the following script-src to your application.
2. Include angular-filter.js (or angular-filter.min.js) in your index.html, after including Angular itself as shown in the below example.
3. Add ‘angular.filter’ to your main module’s list of dependencies.
Example: In this example, we will group dogs by their breeds using angular-filter.
HTML
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js">    </script>          <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.7/angular-filter.js">    </script>          <link rel="stylesheet" href=        "https://www.w3schools.com/w3css/4/w3.css">    <meta charset="utf-8"></head>  <body ng-app="myApp" ng-controller="myCtrl">      <p class="w3-jumbo w3-text-green pad"         align="center" style="margin: 0 0 0 0">        GeeksforGeeks    </p>      <p class="w3-large w3-text-green pad"         align="center">        A computer science portal for geeks    </p>      <ul>        <li ng-repeat=            "(key, value) in dogs | groupBy:'breed'">            Breed: {{ key }}            <ol>                <li ng-repeat="dog in value">                    Dog name: {{ dog.name }}                </li>            </ol>        </li>    </ul>        <script type="text/javascript">        //(3)        angular.module('myApp', ['angular.filter'])            .controller('myCtrl', function ($scope) {            $scope.dogs = [                { name: 'Alex', breed: 'German Shepherd' },                { name: 'Rocky', breed: 'Bulldog' },                { name: 'John', breed: 'Beagle' },                { name: 'Paula', breed: 'Bulldog' },                { name: 'Bobby', breed: 'German Shepherd' }            ];        });    </script></body>  </html>
Output: 
AngularJS-Misc
CSS-Misc
HTML-Misc
AngularJS
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Check for None values in given dictionary

11 Jul, 2019
Many times, while working with dictionaries, we wish to check for a non-null dictionary, i.e check for None values in given dictionary. This finds application in Machine Learning in which we have to feed data with no none values. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using all() + not operator + values()
The combination of above functions can be used to perform this particular task. In this, we check for all the values using all function extracted using values function. The not operator is used to inverse the result to check for any of None value.
# Python3 code to demonstrate working of# Check for Non None Dictionary values# Using all() + not operator + values()  # initializing dictionarytest_dict = {'Gfg' : 1, 'for' : 2, 'CS' : None}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Using all() + not operator + values()# Check for Non None Dictionary valuesres = not all(test_dict.values())  # printing result print("Does Dictionary contain None value ? " + str(res))
The original dictionary is : {'Gfg': 1, 'CS': None, 'for': 2}
Does Dictionary contain None value ? True

 
Method #2 : Using in operator + values()
This task can also be performed using the in operator and values function. We just check for None in all the values extracted using the values function and check for existence using the in operator.
# Python3 code to demonstrate working of# Check for Non None Dictionary values# Using in operator + values()  # initializing dictionarytest_dict = {'Gfg' : 1, 'for' : 2, 'CS' : None}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Using in operator + values()# Check for Non None Dictionary valuesres = None in test_dict.values()  # printing result print("Does Dictionary contain None value ? " + str(res))
The original dictionary is : {'Gfg': 1, 'CS': None, 'for': 2}
Does Dictionary contain None value ? True

Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python time asctime() Method

Pythom time method asctime() converts a tuple or struct_time representing a time as returned by gmtime() or localtime() to a 24-character string of the following form: 'Tue Feb 17 23:21:05 2009'.
Following is the syntax for asctime() method −
time.asctime([t]))

t − This is a tuple of 9 elements or struct_time representing a time as returned by gmtime() or localtime() function.
t − This is a tuple of 9 elements or struct_time representing a time as returned by gmtime() or localtime() function.
This method returns 24-character string of the following form: 'Tue Feb 17 23:21:05 2009'.
The following example shows the usage of asctime() method.
#!/usr/bin/python
import time

t = time.localtime()
print "time.asctime(t): %s " % time.asctime(t)
When we run above program, it produces following result −
time.asctime(t): Tue Feb 17 09:42:58 2009
Python | Ways to remove n characters from start of given string

07 Jun, 2019
Given a string and a number ‘n’, the task is to remove a string of length ‘n’ from the start of the string. Let’s a few methods to solve the given task.Method #1: Using Naive Method
# Python3 code to demonstrate # how to remove 'n' characters from starting# of a string  # Initialising stringini_string1 = 'garg_akshat'  # Initialising number of characters to be removedn = 5  # Printing initial stringprint ("Initial String", ini_string1)  # Removing n characters from string using # Naive methodres = ''for i in range(0, len(ini_string1)):    if i>= n:        res = res + ini_string1[i]          # Printing resultant stringprint ("Resultant String", res)
Initial String garg_akshat
Resultant String akshat

 Method #2: Using replace()
# Python3 code to demonstrate # how to remove 'n' characters from starting# of a string  # Initialising stringini_string1 = 'garg_akshat'  # Initialising number of characters to be removedn = 5  # Printing initial stringprint ("Initial String", ini_string1)  # Removing n characters from string using # replace() functionres = ini_string1.replace(ini_string1[:5], '', 1)          # Printing resultant stringprint ("Resultant String", res)
Initial String garg_akshat
Resultant String akshat

 Method #3: String slicing
# Python3 code to demonstrate # how to remove 'n' characters from starting# of a string  # Initialising stringini_string1 = 'gargakshat123'  # Initialising number of characters to be removedn = 5  # Printing initial stringprint ("Initial String", ini_string1)  # Removing n characters from a string# This argument count length from zero # So length to be stripped is passed n-1res = ini_string1[4:]          # Printing resultant stringprint ("Resultant String", res)     
Initial String gargakshat123
Resultant String akshat123

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is contextual selector in CSS ?

21 Nov, 2021
In this article, we will learn about the contextual selector in CSS & understand the declaration syntax with the help of code examples.A contextual selector is defined as a selector which considers the context where the style is to be applied. In simple words, the specified style is applied to an element only if the element is in the specified context. Context can be defined as a parent/child relationship or ancestor/descendant relationship between different parts of the document. A contextual selector is made up of two or more simple selectors separated by white space. Class, any type, ID selector is considered as a simple selector.
Descendants: It matches all elements which are contained within another element.
Syntax:
div {color: red}
p {color: red;}
For any specific HTML element, we can apply the general CSS property that is required to style that element. The below code example will illustrate the approach for applying the contextual selector.  
Example: In this, there is a parent div tag and its two-child p tags. The parent <p> tag and parent <div> tag turns the elements into red as the program executes.
HTML
<!DOCTYPE html><html> <head>    <title>Contextual Selectors</title>     <style>        div {            color: red;        }         p {            color: red;        }    </style></head> <body>    <div>         <p>Geeks For Geeks</p>          <p>A Computer Science portal for geeks.</p>     </div>          <p>What are Contextual Selectors in CSS?</p> </body> </html>
Output:
But suppose you have to turn only that paragraph into the green which is under div and not the other one outside div. You want both <p> and <div> tags to stay red for the document as a whole, but for elements inside the <div> tag, you need to turn the <p> tag into green. How can you do this?
Well, here comes the real importance of contextual selector. 
Syntax:
div p{color: green;}
Example 2: In this example, any <p> tag that is inside <div> tag, will make it green (and not red like the previous syntax specified). Here, the <p> tag will be made green only in the context of <div> tag.  It will be red in all other contexts. 
HTML
<!DOCTYPE html><html> <head>    <title>Contextual Selectors</title>    <style>        div p {            color: green;        }    </style></head> <body>    <div>         <p>Geeks For Geeks</p>          <p>A Computer Science portal for geeks.</p>     </div>      <p>What are Contextual Selectors in CSS?</p> </body> </html>
Output:
From the above examples, we have seen that how a contextual selector is applied to style an element only if the element is in the specified context.
Hello Geeks! Don’t stop learning now. Get hold of all the important competitive programming concepts with the Web Design for Beginners | HTML  course.
sumitgumber28
CSS-Questions
CSS-Selectors
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install Solidity in Windows?

11 May, 2022
To install solidity on windows ensure that you are using windows 10, as only windows 10 provides built-in Linux Subsystem. With the help of this feature, we can run the Ubuntu terminal on the Windows machine. Below are the steps to setup Solidity on windows:
Step 1: Open control panel on your system and toggle to Windows Subsystem for Linux under Control Panel>Programs>Programs and Features>Turn Windows features on or off.
Step 2: After your system restarts install “Ubuntu LTS 18.04” from Microsoft store and after installation set it up.
Step 3: After setting up Bash install and check necessary dependencies like cURL, Node version manager(NVM), NodeJS and Node Packet Manager(NPM) using the following commands:
Installing cURL :sudo apt-get install curlcurl --version Installing NVM:curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bashnvm --versionInstalling NodeJS and NPM:nvm install nodenode --versionnpm --versionAfter installing the dependencies, install and check solidity compiler solc by using following code:npm install -g solcsolcjs --version
Installing cURL :sudo apt-get install curlcurl --version 
sudo apt-get install curl
curl --version 
Installing NVM:curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bashnvm --version
curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
nvm --version
Installing NodeJS and NPM:nvm install nodenode --versionnpm --version
nvm install node
node --version
npm --version
After installing the dependencies, install and check solidity compiler solc by using following code:npm install -g solcsolcjs --version
npm install -g solc
solcjs --version
how-to-install
Blockchain
How To
Installation Guide
Solidity
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Become a Blockchain Developer?
Storage vs Memory in Solidity
How to connect ReactJS with MetaMask ?
Top 7 Interesting Blockchain Project Ideas for Beginners
Proof of Work (PoW) Consensus
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
Java Tutorial
How to filter object array based on attributes?
Int32.MinValue Field in C# with Examples

08 Apr, 2019
The MinValue property or Field of Int32 Struct is used to represent the minimum possible value of Int32. The value of this field is constant means that a user cannot change the value of this field. The value of this field is -2,147,483,648. Its hexadecimal value is 0x80000000.
Syntax:
public const int MinValue = -2147483648;
Return Value: This field always returns -2147483648.
Example:
// C# program to illustrate the// Int32.MinValue fieldusing System;  class GFG {      // Main Method    static public void Main()    {        // display the Minimum value of Int32 struct        Console.WriteLine("Minimum Value is: "+                               Int32.MinValue);          // Taking an array of long i.e Int64 data type        long []num = {346, 434443, -33445, -442343263647};          // taking variable of Int32 type        int mynum;        foreach(long n in num)        {              if(n >= Int32.MinValue && n <= Int32.MaxValue)            {                  // using the method of Convert class                mynum = Convert.ToInt32(n);                Console.WriteLine("Conversion is Possible.");            }                          else            {                Console.WriteLine("Not Possible");            }        }              }}
Output:
Minimum Value is: -2147483648
Conversion is Possible.
Conversion is Possible.
Conversion is Possible.
Not Possible

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.int32.minvalue?view=netframework-4.7.2
CSharp-Int32-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to .NET Framework
C# | Delegates
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
C# | Data Types
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
C# | Class and Object
Extension Method in C#
Difference between Ref and Out keywords in C#