Pradeep Elance has Published 417 Articles

Delete elements with frequency atmost K in Python

Pradeep Elance

Pradeep Elance

Updated on 04-May-2020 13:04:48

360 Views

While manipulating data from lists we may come across scenario where we have selectively remove elements form the list based on their frequency. In this article we will explore how to remove all elements from a list whose frequency is less than equal to 2. You can also change the ... Read More

Delete elements in range in Python

Pradeep Elance

Pradeep Elance

Updated on 04-May-2020 13:03:02

818 Views

Deleting a single element from a python is straight forward by using the index of the element and the del function. But there may be scenarios when we need to delete elements for a group of indices. This article explores the approaches to delete only those elements form the list ... Read More

Decimal to binary list conversion in Python

Pradeep Elance

Pradeep Elance

Updated on 04-May-2020 13:01:28

795 Views

Python being a versatile language can handle many requirements that comes up during the data processing. When we need to convert a decimal number to a binary number we can use the following python programs.Using formatWe can Use the letter in the formatter to indicate which number base: decimal, hex, ... Read More

Custom list split in Python

Pradeep Elance

Pradeep Elance

Updated on 04-May-2020 13:00:43

498 Views

Data analytics throws complex scenarios where the data need to be wrangled to moved around. In this context let’s see how we can take a big list and split it into many sublists as per the requirement. In this article we will explore the approaches to achieve this.With zip and ... Read More

Create list of numbers with given range in Python

Pradeep Elance

Pradeep Elance

Updated on 04-May-2020 12:59:09

16K+ Views

Python can handle any requirement in data manipulation through its wide variety of libraries and methods. When we need to generate all the numbers between a pair of given numbers, we can use python’s inbuilt functions as well as some of the libraries. This article describes such approaches.Using rangeThe range() ... Read More

Convert list of string to list of list in Python

Pradeep Elance

Pradeep Elance

Updated on 03-Mar-2020 06:34:31

967 Views

In this article we will see how to create a list of lists which contain string data types. The inner list themselves or of string data type and they may contain numeric or strings as their elements.Using strip and splitWe use these two methods which will first separate out the ... Read More

Python - cmp() Method

Pradeep Elance

Pradeep Elance

Updated on 03-Mar-2020 06:30:00

4K+ Views

The cmp() is part of the python standard library which compares two integers. The result of comparison is -1 if the first integer is smaller than second and 1 if the first integer is greater than the second. If both are equal the result of cmp() is zero.Below example illustrates ... Read More

Python - Clearing list as dictionary value

Pradeep Elance

Pradeep Elance

Updated on 03-Mar-2020 06:27:16

167 Views

In this article we consider a dictionary where the values are presented as lists. Then we consider clearing those values from the lists. We have two approaches here. One is to use the clear methods and another is to designate empty values to each key using list comprehension.Example Live Demox1 = ... Read More

Python - Check if frequencies of all characters of a string are different

Pradeep Elance

Pradeep Elance

Updated on 03-Mar-2020 06:21:19

208 Views

In this article we will see how to find the frequency of each character in a given string. Then see if two or more characters have the same frequency in the given string or not. We will accomplish this in two steps. In the first program we will just find ... Read More

Python - Check if dictionary is empty

Pradeep Elance

Pradeep Elance

Updated on 03-Mar-2020 06:17:58

6K+ Views

During analysis of data sets we may come across situations where we have to deal with empty dictionaries. In tis article we will see how to check if a dictionary is empty or not.Using ifThe if condition evaluates to true if the dictionary has elements. Otherwise it evaluates to false. ... Read More

Advertisements