Tag: multiple
Java : Creating HashMap by associating multiple values with same Key
In this article we will discuss how to create a HashMap with multiple values associated with same Key in Java. Suppose we want to create a HashMap to keep the track of strings and their occurrences in text. For example. Advertisements “the” occurred at following indexes 1,4,8,12. “at” occurred at following indexes 22, 28, 44 …
Java : Creating HashMap by associating multiple values with same KeyRead More
Python : How to Remove multiple keys from Dictionary while Iterating ?
In this article we will discuss how to remove multiple key / value pairs from dictionary while iterating. Suppose we have a dictionary of string and int i.e. Advertisements # Dictionary of strings wordFreqDic = { “Hello”: 51, “at” : 23 , “test” : 33, “here” : 63, “start” : 13 } Now we want …
Python : How to Remove multiple keys from Dictionary while Iterating ?Read More
Python : How to remove multiple elements from list ?
In this article we will discuss different ways to remove multiple elements from list. Suppose we have a list of numbers i.e. # List of Numbers listOfnum = [12, 44, 56, 45, 34, 3, 4, 33, 44] Now we want to remove all the numbers from list, which are multiple of 3. Advertisements Remove multiple …
Python : How to remove multiple elements from list ?Read More
Python : How to replace single or multiple characters in a string ?
In this article we will discuss how to replace single or multiple characters in a string in Python. Python provides a str.replace() function i.e. Advertisements str.replace(old, new , count) It returns a new string object that is a copy of existing string with replaced content. Also, If count is not provides then it will return …
Python : How to replace single or multiple characters in a string ?Read 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
Python : *args | How to pass multiple arguments to function ?
In this article we will discuss how to define a function in python that can accept variable length arguments. Suppose we have a function to calculate the average of 3 numbers i.e. Advertisements def average(a , b, c): ”’ Function To calculate the average of 3 numbers ”’ return (a+b+c)/3 Now let’s use this function, …
Python : *args | How to pass multiple arguments to function ?Read More
Python: How to unzip a file | Extract Single, multiple or all files from a ZIP archive
In this article we will discuss different ways to unzip or extract single, multiple or all files from zip archive to current or different directory. In Python’s zipfile module, ZipFile class provides a member function to extract all the contents from a ZIP archive, Advertisements ZipFile.extractall(path=None, members=None, pwd=None) It accepts following arguments : path : …
Python: How to unzip a file | Extract Single, multiple or all files from a ZIP archiveRead More
Python: How to create a zip archive from multiple files or Directory
In this article we will discuss how to create a zip archive from selected files or files from a directory based on filters. Python’s zipfile module provides a ZipFile class for zip file related stuff. Let’s use this to create a zip archive file. Advertisements First import the class from module i.e. from zipfile import …
Python: How to create a zip archive from multiple files or DirectoryRead More
Count occurrences of a single or multiple characters in string and find their index positions
In this article we will discuss different ways to count occurrences of a single character or some selected characters in a string and find their index positions in the string. Count Occurrences of a single character in a String using string.count() In Python the String class contains a method to count to the occurrences of …
Pandas : Change data type of single or multiple columns of Dataframe in Python
In this article we will discuss how to change the data type of a single column or multiple columns of a Dataframe in Python. Change Data Type of a Single Column To change the data type of a single column in dataframe, we are going to use a function series.astype(). Let’s first discuss about this …
Pandas : Change data type of single or multiple columns of Dataframe in PythonRead More