Pradeep Elance has Published 298 Articles

Converting list string to dictionary in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:18:14

1K+ Views

Here we have a scenario where if string is presented which has elements in it making it a list. But those elements can also represent a key-value pair making it dictionary. In this article we will see how to take such a list string and make it a dictionary.With split ... Read More

Converting all strings in list to integers in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:16:45

2K+ Views

Sometimes we can have a list containing strings but the strings themselves are numbers and closing quotes. In such a list we want to convert the string elements into actual integers.With int()The int function takes in parameters and converts it to integers if it is already a number. So we ... Read More

Convert two lists into a dictionary in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:15:54

5K+ Views

While a Python list contains a series of values a dictionary on the other hand contains a pair of values which are called key-value pairs. In this article we will take two lists and mark them together to create a Python dictionary.With for and removeWe create two nested for loops. ... Read More

Convert string to DateTime and vice-versa in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:13:41

292 Views

Python has extensive date and time manipulation capabilities.In this article we'll see in how is string with proper format can we converted to a datetime and the vice versa.With strptimeThis strptime function from datetime module can do the conversion from string to datetime by taking appropriate format specifiers.Example Live Demoimport datetime ... Read More

Convert set into a list in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 11:12:20

388 Views

As part of data analysis using Python we may be required to to convert the data container from set to list. In this article we'll see e how to solve this requirement.With listThis is a straightforward approach in which we directly apply the list function on the given set. The ... Read More

Convert number to list of integers in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 11:10:01

11K+ Views

As part of data manipulation in Python we may sometimes need to convert a given number into a list which contains the digits from that number. In this article we'll see the approaches to achieve this.With list comprehensionIn the below approach we apply the str function to the given number ... Read More

Convert list of tuples into digits in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 11:02:52

236 Views

Python has a wide variety of data manipulation capabilities. We have a scenario in which we are given a list which has elements which are pair of numbers as tuples. In this article we will see how to extract the unique digits from the elements of a list which are ... Read More

Convert list of strings and characters to list of characters in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:58:15

505 Views

While dalign with lists, we may come across a situation where we have to process a string and get its individual characters for further processing. In this article we will see various ways to do that.With list comprehensionWe design a for loop to go through each element of the list ... Read More

Convert dictionary object into string in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:51:52

401 Views

For data manipulation in python we may come across situation to convert a dictionary object into a string object. This can be achieved in the following ways.with str()In this straight forward method we simple apply the str() by passing the dictionary object as a parameter. We can check the type ... Read More

Convert case of elements in a list of strings in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:48:40

3K+ Views

As part of data manipulation, we will come across the need to have a single case for all the letters in a string. In this article we will see how to take a list which has string elements with mixed cases. We then apply some python functions to convert them ... Read More

Advertisements