Pradeep Elance has Published 417 Articles

Change Data Type for one or more columns in Pandas Dataframe

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 11:30:14

2K+ Views

Many times we may need to convert the data types of one or more columns in a pandas data frame to accommodate certain needs of calculations. There are some in-built functions or methods available in pandas which can achieve this.Using astype()The astype() method we can impose a new data type ... Read More

Calculate n + nn + nnn + ? + n(m times) in Python

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 10:47:57

445 Views

There are a variety of mathematical series which python can handle gracefully. One such series is a series of repeated digits. Here we take a digit and add it to the next number which has two such digits and again the next number is three such digits and so on. ... Read More

howdoi in Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:58:23

302 Views

Create a Python ListExampleC:\Py3Project>howdoi create a python listOutputRunning the above code gives us the following result −>>> l = [None] * 10 >>> l [None, None, None, None, None, None, None, None, None, None]Printing Today’s DateExamplec:\python3>howdoi print today's date in pythonOutputRunning the above code gives us the following result −for ... Read More

How to print without newline in Python?

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:57:22

1K+ Views

In python the print statement adds a new line character by default. So when we have multiple print statements the output from each of them is printed in multiple lines as you can see in the example below. Our goal is to print them in a single line and use ... Read More

gcd() function Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:53:53

2K+ Views

Greatest common divisor or gcd is a mathematical expression to find the highest number which can divide both the numbers whose gcd has to be found with the resulting remainder as zero. It has many mathematical applications. Python has a inbuilt gcd function in the math module which can be ... Read More

floor() and ceil() function Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:53:20

2K+ Views

These two methods are part of python math module which helps in getting the nearest integer values of a fractional number.floor()It accepts a number with decimal as parameter and returns the integer which is smaller than the number itself.SyntaxSyntax: floor(x) Where x is a numeric valueExample of floor()In the below ... Read More

How to download Google Images using Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:41:47

1K+ Views

Google offers many python packages which minimize the effort to write python code to get data from google services. One such package is google images download. It takes in the key words as parameters and locates the images with those keywords.ExampleIn the below example we limit the number of images ... Read More

How to clear screen in python?

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:38:47

6K+ Views

In Python sometimes we have link the output and we want to clear the screen in the cell prompt we can clear the screen by pressing Control + l . But there are situations when we need to clear the screen programmatically depending on the amount of output from the ... Read More

frozenset() in Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:31:31

363 Views

This function helps in converting a mutable list to an immutable one. This is needed when we have declared a list whose items are changeable but after certain steps we want to stop allowing the elements in it to change. In such scenario, we apply the frozenset() function as shown ... Read More

float() in Python

Pradeep Elance

Pradeep Elance

Updated on 07-Aug-2019 08:55:11

232 Views

Float method is part of python standard library which converts a number or a string containing numbers to a float data type. There are following rules when a string is considered to be valid for converting it to a float.The string must have only numbers in it.Mathematical operators between the ... Read More

Advertisements