Hafeezul Kareem has Published 345 Articles

Move all zeroes to end of the array using List Comprehension in Python

Hafeezul Kareem

Hafeezul Kareem

Updated on 12-Feb-2020 11:44:21

2K+ Views

Given a list of numbers, move all the zeroes to the end using list comprehensions. For example, the result of [1, 3, 0, 4, 0, 5, 6, 0, 7] is [1, 3, 4, 5, 6, 7, 0, 0, 0].It's a single line code using the list comprehensions. See the following ... Read More

Merge, Join and Concatenate DataFrames using Pandas

Hafeezul Kareem

Hafeezul Kareem

Updated on 12-Feb-2020 11:42:34

1K+ Views

In this tutorial, we are going to learn to merge, join, and concat the DataFrames using pandas library. I think you are already familiar with dataframes and pandas library. Let's see the three operations one by one.MergeWe have a method called pandas.merge() that merges dataframes similar to the database join operations. Follow the ... Read More

Get a google map image of specified location using Google Static Maps API in Python

Hafeezul Kareem

Hafeezul Kareem

Updated on 12-Feb-2020 11:29:57

4K+ Views

Google provides a static maps API that returns a map image on our HTTP request. We can directly request for a map image with different parameters based on our need.We have to create a billing account on Google to use this API. You can go to the website for more ... Read More

Find current weather of any city using OpenWeatherMap API in Python

Hafeezul Kareem

Hafeezul Kareem

Updated on 12-Feb-2020 11:25:39

8K+ Views

In this tutorial, we are going to get the weather of a city using OpenWeatherMap API. To use the OpenWeatherMap API, we have to get the API key. We will get it by creating an account on their website.Create an account and get your API Key. It's free until 60 calls ... Read More

Count frequencies of all elements in array in Python

Hafeezul Kareem

Hafeezul Kareem

Updated on 12-Feb-2020 11:16:43

15K+ Views

In this tutorial, we are going to write a program that finds the frequency of all the elements in an array. We can find it in different ways let's explore two of them.Using dictInitialize the array.Initialize an empty dict.Iterate over the list.If the element is not in dict, then set ... Read More

Count all prefixes in given string with greatest frequency using Python

Hafeezul Kareem

Hafeezul Kareem

Updated on 12-Feb-2020 11:10:44

506 Views

In this tutorial, we are going to write a program that counts and prints the words with a higher frequency of an alphabet than the second one.Take a string and two alphabets. The prefixes with a higher frequency of the first alphabet will be printed. And display the count at ... Read More

Calculate n + nn + nnn + u + n(m times) in Python Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 02-Jan-2020 07:07:04

266 Views

In this tutorial, we are going to write code to find the sum of the series n + nn + nnn + ... + n (m times). We can do it very easily in Python. Let's see some examples.Input: n = 1 m = 5 Series: 1 + 11 + ... Read More

Boolean Indexing in Pandas

Hafeezul Kareem

Hafeezul Kareem

Updated on 02-Jan-2020 06:58:52

2K+ Views

Boolean indexing helps us to select the data from the DataFrames using a boolean vector. We need a DataFrame with a boolean index to use the boolean indexing. Let's see how to achieve the boolean indexing.Create a dictionary of data.Convert it into a DataFrame object with a boolean index as ... Read More

Calendar Functions in Python - ( calendar(), month(), isleap()?)

Hafeezul Kareem

Hafeezul Kareem

Updated on 02-Jan-2020 06:53:15

378 Views

We can perform the calendar operations using the calendar module in Python. Here, we are going to learn about the different methods of calendar class instance.calendar.calendar(year)The calendar class instance returns the calendar of the year. Let's see one example.Example Live Demo# importing the calendar module import calendar # initializing year year ... Read More

Calendar Functions in Python -(monthrange(), prcal(), weekday()?)

Hafeezul Kareem

Hafeezul Kareem

Updated on 02-Jan-2020 06:47:01

457 Views

We are going to explore different methods of calendar module in this tutorial. Let's see one by one.calendar.monthrange(year, month)The method calendar.monthrange(year, month) returns starting weekday number and number of days of the given month. It returns two values in a tuple. Let's see one example.Example Live Demo# importing the calendar module ... Read More

Advertisements