Tag: Index
Python : Check if a String contains a sub string & find it’s index | case insensitive
In this article we will discuss different ways to check if a sub-string exists in another string and if yes then find it’s index. Will also explore ways to check the existence of sub-string in case in-sensitive manner by ignoring case. Check if a String contains another string or character using “in” and “not in” …
Python : Check if a String contains a sub string & find it’s index | case insensitiveRead More
Pandas : How to merge Dataframes by index using Dataframe.merge() – Part 3
In this article we will discuss how to merge two dataframes in index of both the dataframes or index of one dataframe and some column of any other dataframe. Also, we will see how to keep the similar index in merged dataframe. In previous two articles we have discussed about many features of Dataframe.merge(). Therefore …
Pandas : How to merge Dataframes by index using Dataframe.merge() – Part 3Read 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 …
Python: Find duplicates in a list with frequency count & index positions
In this article, we will discuss how to find duplicates in a list along with their frequency count and their index positions in the list. Let’s do this step by step, Advertisements Step 1: Get duplicate elements in a list with a frequency count Suppose we have a list of strings i.e. # List of …
Python: Find duplicates in a list with frequency count & index positionsRead More
Pandas : Convert Dataframe column into an index using set_index() in Python
In this article, we will discuss that in pandas, how to convert an existing column of a Dataframe to an index, and also various scenarios associated with it. Pandas Dataframe class provides a function set_index (). Let’s first have a look at that, Advertisements DataFrame.set_index() DataFrame.set_index(self, keys, drop=True, append=False, inplace=False, verify_integrity=False) It accepts column names in the keys argument and …
Pandas : Convert Dataframe column into an index using set_index() in PythonRead More
Pandas : Convert Dataframe index into column using dataframe.reset_index() in python
In this article, we will discuss how to convert indexes of a dataframe or a multi-index dataframe into its columns. Pandas Dataframe class provides a function to reset the indexes of the dataframe i.e. Dataframe.reset_index() DataFrame.reset_index(self, level=None, drop=False, inplace=False, col_level=0, col_fill=”) It resets the indexes of the dataframe and returns a dataframe with a new index.Important arguments are as follows, …
Pandas : Convert Dataframe index into column using dataframe.reset_index() in pythonRead More
Python: Replace character in string by index position
In this article, we will discuss how to replace a character in a string at a specific position. Then we will also see how to replace multiple characters in a string by index positions. Table of Contents Use Python string slicing to replace nth character in a string Python function to replace a character in …
Python: Replace character in string by index positionRead More
Python: Remove elements from list by index or indices
This article will discuss different ways to remove single or multiple elements from a list by the index positions. Table of Contents Python: Remove an element from a list by index using the pop() function Python: Remove an element from the list by index using del keyword Python: Remove an element from list by index …
Python: Remove elements from list by index or indicesRead More
R: Find the index of an element in the vector ( 4 ways )
Often, we have a requirement to find out the index of the first occurrence of an element in the vector so that some operations can be performed on the same. There are many ways to do the same in R; we will go through a few of them. Let us take a simple example where …
R: Find the index of an element in the vector ( 4 ways )Read More
Python: Iterate over dictionary with index
In this article, we will discuss different ways to iterate over a dictionary by index. Table of Contents Overview of enumerate() Iterate over all key-value pairs of dictionary by index Iterate over all keys of dictionary by index Iterate over all values of dictionary by index For iterating over a sequence by indexing, we can …