Tag: by
Java: How to get all keys by a value in HashMap ? | Search by Value in Map
In this article we will discuss how to search into a Map by value and fetch associated keys to the given value. Suppose we have a map of string and integers i.e. Advertisements HashMap<String, Integer> mapOfWords = new HashMap<String, Integer>() { { put(“John”, 25); put(“at”, 2); put(“from”, 10); put(“is”, 5); put(“the”, 2); put(“hello”, 1); put(“break”, …
Java: How to get all keys by a value in HashMap ? | Search by Value in MapRead More
Python : How to Check if an item exists in list ? | Search by Value or Condition
In this article we will discuss different ways to check if a given element exists in list or not. Table of Contents Introduction Check if element exists in list using python “in” Operator Check if element exist in list using list.count() function Check if element exist in list based on custom logic Introduction Suppose we …
Python : How to Check if an item exists in list ? | Search by Value or ConditionRead More
Python: How to sort a list of tuples by 2nd Item using Lambda Function or Comparator
In this article we will discuss how to sort a list of tuple using 2nd or i th item of tuple. Suppose we have a list of tuple i.e. words and thier frequency count, Advertisements # List of tuples i.e. word and its frequency count wordFreq = [ (‘the’ , 34) , (‘at’ , 23), …
Python: How to sort a list of tuples by 2nd Item using Lambda Function or ComparatorRead More
Python : How to remove element from a list by value or Index | remove() vs pop() vs del
In this article we will discuss different ways to remove an elements from list. Remove an element from List by value using list.remove() Python’s list provides a member function to remove an element from list i.e. Advertisements list.remove(value) It removes the first occurrence of given element from the list. For example, Frequently Asked: Convert a …
Python : How to remove element from a list by value or Index | remove() vs pop() vs delRead More
C++ : How to get element by index in vector | at() vs operator []
In this article we will discuss different techniques to get an element from vector by index or position. In vector elements are indexed from 0 to size() – 1. To access any element in vector by index vector provides two member functions i.e. at() operator[] Let’s discuss them in detail, Advertisements Access an element in …
C++ : How to get element by index in vector | at() vs operator []Read More
Python : How to find keys by value in dictionary ?
In this article we will discuss how to find all keys associated with a given single value or multiple values. Suppose we have a dictionary of words and thier frequency i.e. Advertisements # Dictionary of strings and int dictOfWords = { “hello”: 56, “at” : 23 , “test” : 43, “this” : 97, “here” : …
Python : How to access characters in string by index ?
In this article we will discuss how to access characters in string by index. Accessing characters by index in string | indexof In Python indexing of strings starts from 0 till n-1, where n is the size of string. So characters in string of size n, can be accessed from 0 to n-1. Advertisements Suppose we …
Python : How to access characters in string by index ?Read More
Python : How to Sort a Dictionary by key or Value ?
In this article we will discuss how to sort the contents of dictionary by key or value. Suppose we have a dictionary of string and ints i.e. Advertisements # Dictionary of strings and ints wordsFreqDict = { “hello”: 56, “at” : 23 , “test” : 43, “this” : 43 } Dictionary is like a hash …
Python : How to Sort a Dictionary by key or Value ?Read More
Select Rows & Columns by Name or Index in using loc & iloc
In this article we will discuss different ways to select rows and columns in DataFrame. DataFrame provides indexing labels loc & iloc for accessing the column and rows. Also, operator [] can be used to select columns. Let’s discuss them one by one, Advertisements First create a DataFrame object i.e. students = [ (‘jack’, 34, …
Select Rows & Columns by Name or Index in using loc & ilocRead More
Pandas – Select Rows by conditions on multiple columns
In this article we will discuss different ways to select rows in DataFrame based on condition on single or multiple columns. Following Items will be discussed, Advertisements Select Rows based on value in column Select Rows based on any of the multiple values in column Select Rows based on any of the multiple conditions on …
Pandas – Select Rows by conditions on multiple columnsRead More