Pradeep Elance has Published 337 Articles

Find the k most frequent words from data set in Python

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 08:48:10

1K+ Views

If there is a need to find 10 most frequent words in a data set, python can help us find it using the collections module. The collections module has a counter class which gives the count of the words after we supply a list of words to it. We also ... Read More

Find all the numbers in a string using regular expression in Python

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 08:42:28

918 Views

Extracting only the numbers from a text is a very common requirement in python data analytics. It is done easily using the python regular expression library. This library helps us define the patterns for digits which can be extracted as substrings.ExamplesIn the below example we use the function findall() from ... Read More

Count frequencies of all elements in array in Python using collections module

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 08:18:37

400 Views

As python allows duplicate elements in a list we can have one element present multiple Times. The frequency of elements in a list indicates how many times an element occurs in a list. In this article we use the Counter function of the collections module to find out the frequency ... Read More

Count distinct elements in an array in Python

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 08:15:52

672 Views

In a list in Python we may have duplicate elements. When we count the length of the list we get the total length including the duplicate elements. But in this article we will see how to get the total count of the distinct elements or unique elements in a list.ExampleIn ... Read More

Backward iteration in Python

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 07:52:06

7K+ Views

Sometimes we need to go through the elements of a list in backward order. To achieve this we need to read the last element first and then the last but one and so on till the element at index 0. Various python programming features can be used to achieve this.Using ... Read More

Add a row at top in pandas DataFrame

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 07:33:33

2K+ Views

In Pandas a DataFrame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns. We can create a DataFrame using list, dict, series and another DataFrame. But when we want to add a new row to an already created DataFrame, it is achieved ... Read More

Absolute and Relative Imports in Python

Pradeep Elance

Pradeep Elance

Updated on 30-Jul-2019 22:30:26

736 Views

Many times when we create python code we find that we need to access code from another python file or package. This is when you need to import that other python file or package into your current code. So the straight forward way to achieve this is just written the ... Read More

Advertisements